From 77aa9827fe93f1361d23833ab371cde5192d8c6f Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Fri, 14 Nov 2014 13:06:35 +0200 Subject: [PATCH] Fix candidate to bug #615, http://bugs.skysql.com/show_bug.cgi?id=615 --- server/modules/protocol/mysql_backend.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index 33b114649..aae579d09 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -539,10 +539,13 @@ static int gw_read_backend_event(DCB *dcb) { goto return_rc; } } - /*< - * If dcb->session->client is freed already it may be NULL. + /** + * Check that session is operable, and that client DCB is + * still listening the socket for replies. */ - if (dcb->session->client != NULL) + if (dcb->session->state == SESSION_STATE_ROUTER_READY && + dcb->session->client != NULL && + dcb->session->client->state == DCB_STATE_POLLING) { client_protocol = SESSION_PROTOCOL(dcb->session, MySQLProtocol); @@ -571,6 +574,10 @@ static int gw_read_backend_event(DCB *dcb) { rc = 1; } } + else /*< session is closing; replying to client isn't possible */ + { + gwbuf_free(read_buffer); + } } return_rc: