diff --git a/server/core/poll.c b/server/core/poll.c index 2e37df3c8..35016ca33 100644 --- a/server/core/poll.c +++ b/server/core/poll.c @@ -263,11 +263,17 @@ poll_waitevents(void *arg) { atomic_add(&pollStats.n_error, 1); dcb->func.error(dcb); + if (DCB_ISZOMBIE(dcb)) { + continue; + } } if (ev & EPOLLHUP) { atomic_add(&pollStats.n_hup, 1); dcb->func.hangup(dcb); + if (DCB_ISZOMBIE(dcb)) { + continue; + } } if (ev & EPOLLOUT) { diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index abdecedde..72559cbde 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -360,7 +360,9 @@ static int gw_write_backend_event(DCB *dcb) { /** * Don't write to backend if backend_dcb is not in poll set anymore. */ - if (dcb->state != DCB_STATE_POLLING) { + if (dcb->state != DCB_STATE_POLLING && + dcb->session->client != NULL) + { mysql_send_custom_error( dcb->session->client, 1, diff --git a/server/modules/protocol/mysql_common.c b/server/modules/protocol/mysql_common.c index c5060b8af..2f4119a6d 100644 --- a/server/modules/protocol/mysql_common.c +++ b/server/modules/protocol/mysql_common.c @@ -39,13 +39,33 @@ extern int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue); extern int gw_error_backend_event(DCB *dcb); +/** + * @node Creates MySQL protocol structure + * + * Parameters: + * @param dcb - in, use + * Must be non-NULL. + * + * @return + * + * + * @details (write detailed description here) + * + */ MySQLProtocol* mysql_protocol_init( DCB* dcb) { MySQLProtocol* p; - if (dcb != NULL) { - CHK_DCB(dcb); + CHK_DCB(dcb); + + if (dcb == NULL) { + skygw_log_write_flush( + LOGFILE_ERROR, + "%lu [mysql_init_protocol] MySQL protocol init failed : " + "called with DCB == NULL.", + pthread_self()); + return NULL; } p = (MySQLProtocol *) calloc(1, sizeof(MySQLProtocol)); ss_dassert(p != NULL);