Skip to content

Commit 64a1458

Browse files
committed
Ensure that ER_CONNECTION_KILLED error message is not lost
my_real_read() detects if the connection was killed and sets error to ER_CONNECTION_KILLED. However net_real_write() overrides the error with ER_NET_READ_INTERRUPTED or ER_NET_READ_ERROR when it tries to send the 'Connection was killed' to the user on a closed connection. Fixed by not overwriting the original error code if the connection was shutdown. Rewiewed-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent b12e8d9 commit 64a1458

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sql/net_serv.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -773,18 +773,22 @@ net_real_write(NET *net,const uchar *packet, size_t len)
773773
}
774774
#endif /* !defined(MYSQL_SERVER) */
775775
net->error= 2; /* Close socket */
776-
net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED :
777-
ER_NET_ERROR_ON_WRITE);
778-
#ifdef MYSQL_SERVER
779-
if (global_system_variables.log_warnings > 3)
776+
777+
if (net->vio->state != VIO_STATE_SHUTDOWN || net->last_errno == 0)
780778
{
781-
sql_print_warning("Could not write packet: fd: %lld state: %d "
782-
"errno: %d vio_errno: %d length: %ld",
783-
(longlong) vio_fd(net->vio), (int) net->vio->state,
784-
vio_errno(net->vio), net->last_errno,
785-
(ulong) (end-pos));
786-
}
779+
net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED :
780+
ER_NET_ERROR_ON_WRITE);
781+
#ifdef MYSQL_SERVER
782+
if (global_system_variables.log_warnings > 3)
783+
{
784+
sql_print_warning("Could not write packet: fd: %lld state: %d "
785+
"errno: %d vio_errno: %d length: %ld",
786+
(longlong) vio_fd(net->vio), (int) net->vio->state,
787+
vio_errno(net->vio), net->last_errno,
788+
(ulong) (end-pos));
789+
}
787790
#endif
791+
}
788792
MYSQL_SERVER_my_error(net->last_errno, MYF(0));
789793
break;
790794
}

0 commit comments

Comments
 (0)