@@ -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 (¤t_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;
0 commit comments