Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create #define for network buffer alignment #267

Open
wants to merge 1 commit into
base: 3.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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