Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit 5743dda

Browse files
committed
Merge branch 'mysql-8.0' into mysql-trunk
Change-Id: I15491b3717db846982954ba55fa2527c8a199aa1
2 parents 963680c + 4ff84b4 commit 5743dda

6 files changed

Lines changed: 27 additions & 5 deletions

File tree

‎include/mysql_com_server.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ typedef struct NET_SERVER {
6161
void *m_user_data;
6262
struct compression_attributes compression;
6363
mysql_compress_context compress_ctx;
64+
bool timeout_on_full_packet;
6465
} NET_SERVER;
6566

6667
#endif

‎sql-common/net_serv.cc‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,15 @@ static bool net_read_raw_loop(NET *net, size_t count) {
13441344
bool eof = false;
13451345
unsigned int retry_count = 0;
13461346
uchar *buf = net->buff + net->where_b;
1347+
bool timeout_on_full_packet = false;
1348+
bool is_packet_timeout = false;
1349+
#ifdef MYSQL_SERVER
1350+
NET_SERVER *server_ext = static_cast<NET_SERVER *>(net->extension);
1351+
if (server_ext) timeout_on_full_packet = server_ext->timeout_on_full_packet;
1352+
#endif
13471353

1354+
time_t start_time;
1355+
if (timeout_on_full_packet) start_time = time(&start_time);
13481356
while (count) {
13491357
size_t recvcnt = vio_read(net->vio, buf, count);
13501358

@@ -1367,19 +1375,26 @@ static bool net_read_raw_loop(NET *net, size_t count) {
13671375
#ifdef MYSQL_SERVER
13681376
thd_increment_bytes_received(recvcnt);
13691377
#endif
1378+
if (timeout_on_full_packet) {
1379+
time_t current_time = time(&current_time);
1380+
if (current_time - start_time > net->read_timeout) {
1381+
is_packet_timeout = true;
1382+
break;
1383+
}
1384+
}
13701385
}
13711386

13721387
/* On failure, propagate the error code. */
13731388
if (count) {
13741389
/* Interrupted by a timeout? */
1375-
if (!eof && vio_was_timeout(net->vio))
1390+
if (!eof && (vio_was_timeout(net->vio) || is_packet_timeout))
13761391
net->last_errno = ER_NET_READ_INTERRUPTED;
13771392
else
13781393
net->last_errno = ER_NET_READ_ERROR;
13791394

13801395
#ifdef MYSQL_SERVER
13811396
/* First packet always wait for net_wait_timeout */
1382-
if (net->pkt_nr == 0 && vio_was_timeout(net->vio)) {
1397+
if (net->pkt_nr == 0 && (vio_was_timeout(net->vio) || is_packet_timeout)) {
13831398
net->last_errno = ER_CLIENT_INTERACTION_TIMEOUT;
13841399
/* Socket should be closed after trying to write/send error. */
13851400
THD *thd = current_thd;

‎sql/conn_handler/init_net_server_extension.cc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ void init_net_server_extension(THD *thd) {
123123
thd->m_net_server_extension.m_before_header = net_before_header_psi;
124124
thd->m_net_server_extension.m_after_header = net_after_header_psi;
125125
thd->m_net_server_extension.compress_ctx.algorithm = MYSQL_UNCOMPRESSED;
126+
thd->m_net_server_extension.timeout_on_full_packet = false;
126127
/* Activate this private extension for the mysqld server. */
127128
thd->get_protocol_classic()->get_net()->extension =
128129
&thd->m_net_server_extension;

‎sql/protocol_classic.cc‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,8 +1356,12 @@ bool Protocol_classic::send_error(uint sql_errno, const char *err_msg,
13561356
return retval;
13571357
}
13581358

1359-
void Protocol_classic::set_read_timeout(ulong read_timeout) {
1359+
void Protocol_classic::set_read_timeout(ulong read_timeout,
1360+
bool on_full_packet) {
13601361
my_net_set_read_timeout(&m_thd->net, read_timeout);
1362+
NET_SERVER *ext = static_cast<NET_SERVER *>(m_thd->net.extension);
1363+
assert(ext);
1364+
ext->timeout_on_full_packet = on_full_packet;
13611365
}
13621366

13631367
void Protocol_classic::set_write_timeout(ulong write_timeout) {

‎sql/protocol_classic.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ class Protocol_classic : public Protocol {
198198
/* Return raw packet buffer */
199199
uchar *get_raw_packet() { return input_raw_packet; }
200200
/* Set read timeout */
201-
virtual void set_read_timeout(ulong read_timeout);
201+
virtual void set_read_timeout(ulong read_timeout,
202+
bool on_full_packet = false);
202203
/* Set write timeout */
203204
virtual void set_write_timeout(ulong write_timeout);
204205

‎sql/sql_connect.cc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static bool login_connection(THD *thd) {
699699
("login_connection called by thread %u", thd->thread_id()));
700700

701701
/* Use "connect_timeout" value during connection phase */
702-
thd->get_protocol_classic()->set_read_timeout(connect_timeout);
702+
thd->get_protocol_classic()->set_read_timeout(connect_timeout, true);
703703
thd->get_protocol_classic()->set_write_timeout(connect_timeout);
704704

705705
error = check_connection(thd);

0 commit comments

Comments
 (0)