summaryrefslogtreecommitdiff
path: root/sql/net_serv.cc
diff options
context:
space:
mode:
authorMichael Widenius <monty@askmonty.org>2014-07-19 13:38:40 +0300
committerMichael Widenius <monty@askmonty.org>2014-07-19 13:38:40 +0300
commitff205b25d543f87c8b79afc3ea0013017e751cd9 (patch)
tree73b4020189b43e041b5de228e3cbd2b1c4d4c177 /sql/net_serv.cc
parent54538b481d0adac73da7054740122d05611cffac (diff)
downloadmariadb-git-ff205b25d543f87c8b79afc3ea0013017e751cd9.tar.gz
Fixed assert in perfschema/pfs.cc::start_idle_wait_v1 when using performance schema and big packets in debug version.
The bug was that my_real_read() called net_before_header_psi() multiple times for long packets. Fixed by adding a flag when we are reading a header. Did also some cleanups to interface of my_net_read() to avoid unnecessary calls if performance schema is not used. - Added my_net_read_packet() as a replacement for my_net_read(). my_net_read() is still in the client library for old clients. - Removed THD->m_server_idle (not needed anymore as this is now given as argument to my_net_read_packet() - Added my_net_read_packet(), which is a new version of my_net_read() with a new parameter if we are doing a read for a new command from the server. - Added tests for compressed protocol and big packets include/mysql.h.pp: Added my_net_read_packet() as a replacement for my_net_read() include/mysql_com.h: Added my_net_read_packet() as a replacement for my_net_read() mysql-test/r/mysql_client_test_comp.result: New test mysql-test/t/mysql_client_test-master.opt: Added max_allowed_packet to be able to test big packets and packet size overflows. mysql-test/t/mysql_client_test_comp-master.opt: New test mysql-test/t/mysql_client_test_nonblock-master.opt: Added max_allowed_packet to be able to test big packets and packet size overflows. sql-common/client.c: Use my_net_read_packet() sql/mf_iocache.cc: Use my_net_read_packet() sql/mysqld.cc: Removed THD->m_server_idle (not needed anymore as this is now given as argument to my_net_read_packet() sql/net_serv.cc: Added argument to my_real_read() to indicte if we are reading the first block of the next statement and should call performance schema. Added 'compatibilty function' my_net_read(). Added my_net_read_packet(), which is a new version of my_net_read() with a new parameter if we are doing a read for a new command from the server. sql/sql_class.cc: Removed m_server_idle (not needed anymore) sql/sql_class.h: Removed m_server_idle (not needed anymore) sql/sql_parse.cc: Removed m_server_idle (not needed anymore) tests/mysql_client_test.c: Added tests for compressed protocol and big packets
Diffstat (limited to 'sql/net_serv.cc')
-rw-r--r--sql/net_serv.cc43
1 files changed, 31 insertions, 12 deletions
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 546542fa207..eb34fcc2d77 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -824,7 +824,8 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed,
*/
static ulong
-my_real_read(NET *net, size_t *complen)
+my_real_read(NET *net, size_t *complen,
+ my_bool header __attribute__((unused)))
{
uchar *pos;
size_t length;
@@ -839,14 +840,16 @@ my_real_read(NET *net, size_t *complen)
NET_HEADER_SIZE);
#ifdef MYSQL_SERVER
size_t count= remain;
- struct st_net_server *server_extension;
- server_extension= static_cast<st_net_server*> (net->extension);
- if (server_extension != NULL)
+ struct st_net_server *server_extension= 0;
+
+ if (header)
{
- void *user_data= server_extension->m_user_data;
- DBUG_ASSERT(server_extension->m_before_header != NULL);
- DBUG_ASSERT(server_extension->m_after_header != NULL);
- server_extension->m_before_header(net, user_data, count);
+ server_extension= static_cast<st_net_server*> (net->extension);
+ if (server_extension != NULL)
+ {
+ void *user_data= server_extension->m_user_data;
+ server_extension->m_before_header(net, user_data, count);
+ }
}
#endif
@@ -1042,6 +1045,16 @@ end:
}
+/* Old interface. See my_net_read_packet() for function description */
+
+#undef my_net_read
+
+ulong my_net_read(NET *net)
+{
+ return my_net_read_packet(net, 0);
+}
+
+
/**
Read a packet from the client/server and return it without the internal
package header.
@@ -1053,13 +1066,17 @@ end:
If the packet was compressed, its uncompressed and the length of the
uncompressed packet is returned.
+ read_from_server is set when the server is reading a new command
+ from the client.
+
@return
The function returns the length of the found packet or packet_error.
net->read_pos points to the read data.
*/
+
ulong
-my_net_read(NET *net)
+my_net_read_packet(NET *net, my_bool read_from_server)
{
size_t len, complen;
@@ -1069,7 +1086,7 @@ my_net_read(NET *net)
if (!net->compress)
{
#endif
- len = my_real_read(net,&complen);
+ len = my_real_read(net,&complen, read_from_server);
if (len == MAX_PACKET_LENGTH)
{
/* First packet of a multi-packet. Concatenate the packets */
@@ -1079,7 +1096,7 @@ my_net_read(NET *net)
{
net->where_b += len;
total_length += len;
- len = my_real_read(net,&complen);
+ len = my_real_read(net,&complen, 0);
} while (len == MAX_PACKET_LENGTH);
if (len != packet_error)
len+= total_length;
@@ -1171,11 +1188,13 @@ my_net_read(NET *net)
}
net->where_b=buf_length;
- if ((packet_len = my_real_read(net,&complen)) == packet_error)
+ if ((packet_len = my_real_read(net,&complen, read_from_server))
+ == packet_error)
{
MYSQL_NET_READ_DONE(1, 0);
return packet_error;
}
+ read_from_server= 0;
if (my_uncompress(net->buff + net->where_b, packet_len,
&complen))
{