From eb3a9667fc714b5c1de0dfde1f19c83b574b7221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 20 Sep 2017 10:19:51 +0300 Subject: [PATCH] Discard connections on interrupted COM_CHANGE_USER Close the connection if a COM_QUIT is received while the COM_CHANGE_USER is in progress. --- .../protocol/MySQL/MySQLBackend/mysql_backend.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c index 5999c4052..32c292301 100644 --- a/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/MySQLBackend/mysql_backend.c @@ -1027,12 +1027,11 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) if (MYSQL_IS_COM_QUIT((uint8_t*)GWBUF_DATA(queue))) { /** The COM_CHANGE_USER was already sent but the session is already - * closing. We ignore the COM_QUIT in the hopes that the response - * to the COM_CHANGE_USER comes before the DCB is closed. If the - * DCB is closed before the response arrives, the connection will - * not qualify the persistent connection pool. */ - MXS_INFO("COM_QUIT received while COM_CHANGE_USER is in progress, ignoring"); + * closing. */ + MXS_INFO("COM_QUIT received while COM_CHANGE_USER is in progress, closing pooled connection"); gwbuf_free(queue); + poll_fake_hangup_event(dcb); + rc = 0; } else { @@ -1044,8 +1043,9 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue) */ MXS_INFO("COM_CHANGE_USER in progress, appending query to queue"); backend_protocol->stored_query = gwbuf_append(backend_protocol->stored_query, queue); + rc = 1; } - return 1; + return rc; } /**