From e03d2b3ffe288043f176be3beee8a00480d672a0 Mon Sep 17 00:00:00 2001 From: vraatikka Date: Fri, 27 Sep 2013 14:57:53 +0300 Subject: [PATCH] In gw_read_client_event, if ioctl returns non-zero and 'b' (number of readable bytes) is zero, that indicates that socket is closed. Thus, read is now skipped and dcb closed if it is in DSC_STATE_POLLING state. --- server/modules/protocol/mysql_client.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index 02974aee2..2764737a1 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -536,9 +536,26 @@ int gw_read_client_event(DCB* dcb) { dcb->state); rc = 1; goto return_rc; - } else { - //fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b); } + + /** + * Socket was closed. + */ + if (b == 0) { + skygw_log_write( + LOGFILE_TRACE, + "%lu [gw_read_client_event] Dcb %p fd %d was closed. " + "Closing dcb.", + pthread_self(), + dcb, + dcb->fd); + + if (dcb->state == DCB_STATE_POLLING) { + dcb->func.close(dcb); + } + rc = 0; + goto return_rc; + } switch (protocol->state) { case MYSQL_AUTH_SENT: