From 9de08dd9a2d701a9aa1e73623737350cb6ced50b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Thu, 18 Dec 2014 09:18:49 +0000 Subject: [PATCH] Issue #51 --- include/mysql_data_stream.h | 2 ++ include/mysql_session.h | 2 +- lib/Standard_ProxySQL_Admin.cpp | 2 +- lib/mysql_data_stream.cpp | 6 +++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/mysql_data_stream.h b/include/mysql_data_stream.h index eeeaaca08..5aa1db18c 100644 --- a/include/mysql_data_stream.h +++ b/include/mysql_data_stream.h @@ -79,6 +79,8 @@ class MySQL_Data_Stream int active; // data stream is active. If not, shutdown+close needs to be called int status; // status . FIXME: make it a ORable variable + bool net_failure; + MySQL_Data_Stream(); ~MySQL_Data_Stream(); diff --git a/include/mysql_session.h b/include/mysql_session.h index 4b03fb15f..c9747263b 100644 --- a/include/mysql_session.h +++ b/include/mysql_session.h @@ -38,7 +38,7 @@ class MySQL_Session // char *schema_name; // char *schema_cur; // char *schema_new; - int net_failure; + //int net_failure; MySQL_Data_Stream *client_myds; MySQL_Data_Stream *server_myds; diff --git a/lib/Standard_ProxySQL_Admin.cpp b/lib/Standard_ProxySQL_Admin.cpp index 6c3b532d4..ea2fbc775 100644 --- a/lib/Standard_ProxySQL_Admin.cpp +++ b/lib/Standard_ProxySQL_Admin.cpp @@ -294,7 +294,7 @@ void *child_mysql(void *arg) { } myds->revents=fds[0].revents; myds->read_from_net(); - if (sess->net_failure) goto __exit_child_mysql; + if (myds->net_failure) goto __exit_child_mysql; myds->read_pkts(); sess->to_process=1; int rc=sess->handler(); diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index c0c053fc8..5ad9ddcae 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -112,6 +112,7 @@ MySQL_Data_Stream::MySQL_Data_Stream() { DSS=STATE_NOT_CONNECTED; encrypted=false; ssl=NULL; + net_failure=false; // ssl_ctx=NULL; } @@ -189,15 +190,18 @@ void MySQL_Data_Stream::init(enum MySQL_DS_type _type, MySQL_Session *_sess, int // Soft shutdown of socket : it only deactivate the data stream +// TODO: should check the status of the data stream, and identify if it is safe to reconnect or if the session should be destroyed void MySQL_Data_Stream::shut_soft() { proxy_debug(PROXY_DEBUG_NET, 4, "Shutdown soft fd=%d. Session=%p, DataStream=%p\n", fd, sess, this); active=FALSE; - if (sess) sess->net_failure=1; + net_failure=true; + //if (sess) sess->net_failure=1; } // Hard shutdown of socket void MySQL_Data_Stream::shut_hard() { proxy_debug(PROXY_DEBUG_NET, 4, "Shutdown hard fd=%d. Session=%p, DataStream=%p\n", fd, sess, this); + net_failure=true; if (fd >= 0) { shutdown(fd, SHUT_RDWR); close(fd);