From e5226f964802b0ee27974e3bd07287cbcab75382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 8 May 2019 17:58:48 +1000 Subject: [PATCH] Do not try to gracefully close a not fully established connection --- lib/mysql_connection.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index 856b07186b..91e4995617 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -231,19 +231,20 @@ MySQL_Connection::~MySQL_Connection() { } if (mysql) { // always decrease the counter - if (ret_mysql) + if (ret_mysql) { __sync_fetch_and_sub(&MyHGM->status.server_connections_connected,1); - if (query.stmt_result) { - if (query.stmt_result->handle) { - query.stmt_result->handle->status = MYSQL_STATUS_READY; // avoid calling mthd_my_skip_result() + if (query.stmt_result) { + if (query.stmt_result->handle) { + query.stmt_result->handle->status = MYSQL_STATUS_READY; // avoid calling mthd_my_skip_result() + } } - } - if (mysql_result) { - if (mysql_result->handle) { - mysql_result->handle->status = MYSQL_STATUS_READY; // avoid calling mthd_my_skip_result() + if (mysql_result) { + if (mysql_result->handle) { + mysql_result->handle->status = MYSQL_STATUS_READY; // avoid calling mthd_my_skip_result() + } } + async_free_result(); } - async_free_result(); close_mysql(); // this take care of closing mysql connection mysql=NULL; } @@ -1680,7 +1681,7 @@ void MySQL_Connection::optimize() { // if avoids that a QUIT command stops forever // FIXME: currently doesn't support encryption and compression void MySQL_Connection::close_mysql() { - if ((send_quit) && (mysql->net.vio)) { + if ((send_quit) && (mysql->net.vio) && ret_mysql) { char buff[5]; mysql_hdr myhdr; myhdr.pkt_id=0;