Skip to content

Commit 0eb34a2

Browse files
authored
Merge pull request #267 from ericherman/eherman-io-size-20241231
Create #define for network buffer alignment
2 parents d3facb7 + f5319d9 commit 0eb34a2

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

include/ma_global.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
412412
/* #define FN_NO_CASE_SENCE */
413413
/* #define FN_UPPER_CASE TRUE */
414414

415-
/*
416-
Io buffer size; Must be a power of 2 and a multiple of 512. May be
417-
smaller what the disk page size. This influences the speed of the
418-
isam btree library. eg to big to slow.
419-
*/
420-
#define IO_SIZE 4096
421415
/*
422416
How much overhead does malloc have. The code often allocates
423417
something like 1024-MALLOC_OVERHEAD bytes

libmariadb/ma_net.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141

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

44+
#ifndef NET_BUF_ALIGN
45+
#define NET_BUF_ALIGN 4096U
46+
#endif
47+
#define align_network_buffer(len) (((len)+NET_BUF_ALIGN-1) & ~(NET_BUF_ALIGN-1))
48+
4449
/* net_buffer_length and max_allowed_packet are defined in mysql.h
4550
See bug conc-57
4651
*/
@@ -128,7 +133,7 @@ static my_bool net_realloc(NET *net, size_t length)
128133
net->pvio->set_error(net->pvio->mysql, CR_NET_PACKET_TOO_LARGE, SQLSTATE_UNKNOWN, 0);
129134
return(1);
130135
}
131-
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
136+
pkt_length = align_network_buffer(length);
132137
/* reallocate buffer:
133138
size= pkt_length + NET_HEADER_SIZE + COMP_HEADER_SIZE */
134139
if (!(buff=(uchar*) realloc(net->buff,

0 commit comments

Comments
 (0)