From bb53eb0f6d865b103bf46589c3769c1d2c409830 Mon Sep 17 00:00:00 2001 From: counterpoint Date: Wed, 7 Oct 2015 17:06:21 +0100 Subject: [PATCH] Put extra check in hashtable_fetch to return if zero entries (should never happen but will crash if not checked); remove dcb_close from mysql_backend where it closes backend DCBs, as these should be closed by the router. --- server/core/hashtable.c | 2 +- server/modules/protocol/mysql_backend.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/core/hashtable.c b/server/core/hashtable.c index 7fd45e898..dbcd56fd9 100644 --- a/server/core/hashtable.c +++ b/server/core/hashtable.c @@ -379,7 +379,7 @@ hashtable_fetch(HASHTABLE *table, void *key) unsigned int hashkey; HASHENTRIES *entry; - if(table == NULL || key == NULL) + if(table == NULL || key == NULL || 0 == table->hashsize) return NULL; hashkey = table->hashfn(key) % table->hashsize; diff --git a/server/modules/protocol/mysql_backend.c b/server/modules/protocol/mysql_backend.c index 4874697fa..d6ada9fa8 100644 --- a/server/modules/protocol/mysql_backend.c +++ b/server/modules/protocol/mysql_backend.c @@ -44,6 +44,7 @@ * 24/10/2014 Massimiliano Pinto Added Mysql user@host @db authentication support * 10/11/2014 Massimiliano Pinto Client charset is passed to backend * 19/06/2015 Martin Brampton Persistent connection handling + * 07/10/2015 Martin Brampton Remove calls to dcb_close - should be done by routers * */ #include @@ -408,7 +409,12 @@ static int gw_read_backend_event(DCB *dcb) { { gwbuf_free(errbuf); dcb->dcb_errhandle_called = true; - dcb_close(dcb); + /* + * I'm pretty certain this is best removed and + * causes trouble if present, but have left it + * here just for now as a comment. Martin + */ + /* dcb_close(dcb); */ rc = 1; goto return_rc; } @@ -1129,7 +1135,12 @@ gw_backend_hangup(DCB *dcb) } } gwbuf_free(errbuf); - dcb_close(dcb); + /* + * I'm pretty certain this is best removed and + * causes trouble if present, but have left it + * here just for now as a comment. Martin + */ + /* dcb_close(dcb); */ goto retblock; } #if defined(SS_DEBUG)