Skip to content

Commit

Permalink
Create #define for network buffer alignment
Browse files Browse the repository at this point in the history
The server's definition of IO_SIZE is re-used here in the client for
network buffer alignment, however IO_SIZE is used in the server for
many different things and the client's buffer alignment is not related
to many of those uses.

If the server is to make IO_SIZE configurable, we need to avoid either
redefining it, or defining it to be different. By creating a specific
define for this, we avoid redfine and clarify the code.

See: MariaDB/server#3726

Signed-off-by: Eric Herman <[email protected]>
  • Loading branch information
ericherman committed Jan 5, 2025
1 parent 52d0a38 commit f470e4b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 0 additions & 6 deletions include/ma_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
/* #define FN_NO_CASE_SENCE */
/* #define FN_UPPER_CASE TRUE */

/*
Io buffer size; Must be a power of 2 and a multiple of 512. May be
smaller what the disk page size. This influences the speed of the
isam btree library. eg to big to slow.
*/
#define IO_SIZE 4096
/*
How much overhead does malloc have. The code often allocates
something like 1024-MALLOC_OVERHEAD bytes
Expand Down
7 changes: 6 additions & 1 deletion libmariadb/ma_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@

#define MAX_PACKET_LENGTH (256L*256L*256L-1)

#ifndef NET_BUF_ALIGN
#define NET_BUF_ALIGN 4096U
#endif
#define align_network_buffer(len) (((len)+NET_BUF_ALIGN-1) & ~(NET_BUF_ALIGN-1))

/* net_buffer_length and max_allowed_packet are defined in mysql.h
See bug conc-57
*/
Expand Down Expand Up @@ -128,7 +133,7 @@ static my_bool net_realloc(NET *net, size_t length)
net->pvio->set_error(net->pvio->mysql, CR_NET_PACKET_TOO_LARGE, SQLSTATE_UNKNOWN, 0);
return(1);
}
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
pkt_length = align_network_buffer(length);
/* reallocate buffer:
size= pkt_length + NET_HEADER_SIZE + COMP_HEADER_SIZE */
if (!(buff=(uchar*) realloc(net->buff,
Expand Down

0 comments on commit f470e4b

Please sign in to comment.