From b01cf2365e5d16c93b5039b43fee587b2b761641 Mon Sep 17 00:00:00 2001 From: Massimiliano Pinto Date: Wed, 4 Sep 2013 15:31:04 +0200 Subject: [PATCH] Added log error or ss_dassert instead of silent returning --- server/modules/protocol/mysql_backend.c | 11 +++++++++++ server/modules/protocol/mysql_client.c | 19 +++++++++++++------ server/modules/protocol/mysql_common.c | 6 ++---- server/modules/routing/readconnroute.c | 7 ++++--- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index ce7d91b89..b9c7d832d 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -152,10 +152,21 @@ static int gw_read_backend_event(DCB *dcb) { CHK_SESSION(dcb->session); if (dcb->session->client == NULL) { dcb->state = DCB_STATE_DISCONNECTED; + skygw_log_write( + LOGFILE_ERROR, + "%lu [gw_read_backend_event] client dcb is NULL for backend dcb %d.", + pthread_self(), + dcb->fd); + dcb->state = DCB_STATE_DISCONNECTED; return 1; } client_protocol = SESSION_PROTOCOL(dcb->session, MySQLProtocol); } else { + skygw_log_write( + LOGFILE_ERROR, + "%lu [gw_read_backend_event] dcb->session is NULL for backend dcb %d.", + pthread_self(), + dcb->fd); dcb->state = DCB_STATE_DISCONNECTED; return 1; } diff --git a/server/modules/protocol/mysql_client.c b/server/modules/protocol/mysql_client.c index 3fecce9d4..debcd4322 100644 --- a/server/modules/protocol/mysql_client.c +++ b/server/modules/protocol/mysql_client.c @@ -662,12 +662,19 @@ int gw_read_client_event(DCB* dcb) { * no connected backends from %i\n", dcb->fd); */ (dcb->func).close(dcb); } else { - /* Send a custom error as MySQL command reply */ - mysql_send_custom_error( - dcb, - 1, - 0, - "Connection to backend lost"); + /* Send a custom error as MySQL command reply */ + if (dcb) { + mysql_send_custom_error( + dcb, + 1, + 0, + "Connection to backend lost"); + } else { + skygw_log_write( + LOGFILE_ERROR, + "%lu [mysql_send_custom_error] client dcb is NULL.", + pthread_self()); + } protocol->state = MYSQL_IDLE; } rc = 1; diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index cbf2a4262..dc713061f 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -23,7 +23,7 @@ * Date Who Description * 17/06/2013 Massimiliano Pinto Common MySQL protocol routines * 02/06/2013 Massimiliano Pinto MySQL connect asynchronous phases - * 04/09/2013 Massimiliano Pinto Added dcb NULL check in mysql_send_custom_error + * 04/09/2013 Massimiliano Pinto Added dcb NULL assert in mysql_send_custom_error * */ @@ -620,9 +620,7 @@ mysql_send_custom_error (DCB *dcb, int packet_number, int in_affected_rows, cons GWBUF *buf = NULL; - if (dcb == NULL) { - return -1; - } + ss_dassert(dcb != NULL); mysql_errno = 2003; mysql_error_msg = "An errorr occurred ..."; diff --git a/server/modules/routing/readconnroute.c b/server/modules/routing/readconnroute.c index 9f2c451ba..9e7efe418 100644 --- a/server/modules/routing/readconnroute.c +++ b/server/modules/routing/readconnroute.c @@ -523,8 +523,9 @@ clientReply( DCB *client = NULL; client = backend_dcb->session->client; - if (client) { - client->func.write(client, queue); - } + + ss_dassert(client != NULL); + + client->func.write(client, queue); } ///