From 3e41779f7ecbb30c41b4fc9c7b6ff3c3f8692e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Tue, 3 Feb 2015 01:20:37 +0000 Subject: [PATCH] If client disconnect, active backends are destroyed --- lib/MySQL_Session.cpp | 6 +++--- lib/Standard_MySQL_Thread.cpp | 2 +- lib/mysql_backend.cpp | 12 ++++++------ lib/mysql_connection.cpp | 6 ++++++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index f3e840859..0ffd0af05 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -123,9 +123,9 @@ MySQL_Session::~MySQL_Session() { if (client_myds) { delete client_myds; } - if (server_myds) { - delete server_myds; - } + //if (server_myds) { + // delete server_myds; + //} reset_all_backends(); delete mybes; proxy_debug(PROXY_DEBUG_NET,1,"Thread=%p, Session=%p -- Shutdown Session %p\n" , this->thread, this, this); diff --git a/lib/Standard_MySQL_Thread.cpp b/lib/Standard_MySQL_Thread.cpp index c1ad668c1..58369ff72 100644 --- a/lib/Standard_MySQL_Thread.cpp +++ b/lib/Standard_MySQL_Thread.cpp @@ -577,7 +577,7 @@ virtual void run() { proxy_debug(PROXY_DEBUG_NET,5,"%s\n", "Returning poll"); curtime=monotonic_time(); - if (curtime>oldtime+mysql_thread___poll_timeout) { + if (curtime>(oldtime+(mysql_thread___poll_timeout*1000))) { oldtime=curtime; GloQPro->update_query_processor_stats(); } diff --git a/lib/mysql_backend.cpp b/lib/mysql_backend.cpp index 404cfe756..abc8f11c0 100644 --- a/lib/mysql_backend.cpp +++ b/lib/mysql_backend.cpp @@ -155,12 +155,8 @@ MySQL_Backend::~MySQL_Backend() { } void MySQL_Backend::reset() { - if (server_myds) { - //delete server_myds; - server_myds=NULL; - } if (myconn) { - if (myconn->reusable==true && ((myconn->myds->sess->myprot_server.prot_status & SERVER_STATUS_IN_TRANS)==0)) { + if (server_myds->DSS==STATE_READY && myconn->reusable==true && ((myconn->myds->sess->myprot_server.prot_status & SERVER_STATUS_IN_TRANS)==0)) { //server_myds->myconn=NULL; //delete myconn; MyHGM->push_MyConn_to_pool(myconn); @@ -169,12 +165,16 @@ void MySQL_Backend::reset() { } else { // MyConnArray *MCA=MyConnPool->MyConnArray_lookup(myconn->mshge->MSptr->address, myconn->myconn.user, myconn->mshge->MSptr->password, myconn->mshge->MSptr->db, myconn->mshge->MSptr->port); MyHGM->destroy_MyConn_from_pool(myconn); - delete myconn; + //delete myconn; } }; //if (mshge) { // FIXME: what to do with it? //} + if (server_myds) { + delete server_myds; + //server_myds=NULL; + } } diff --git a/lib/mysql_connection.cpp b/lib/mysql_connection.cpp index c27d8613d..6cb895cb9 100644 --- a/lib/mysql_connection.cpp +++ b/lib/mysql_connection.cpp @@ -99,6 +99,12 @@ MySQL_Connection::~MySQL_Connection() { delete userinfo; userinfo=NULL; } + if (myds) { + myds->shut_hard(); + } else { + shutdown(fd, SHUT_RDWR); + close(fd); + } };