From ffce4797805a7ee093220e154d51ede79eafa995 Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Sat, 10 May 2014 22:21:30 +0300 Subject: [PATCH] backend connection counter was decreased in freeSession even for those backends which weren't connected. This resulted negative counts and affected on selection algorithm. --- server/modules/routing/readwritesplit/readwritesplit.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index 02bdcc903..96a7474a3 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -648,8 +648,7 @@ static void closeSession( if (dcb != NULL) { CHK_DCB(dcb); - backend_ref[i].bref_dcb = - (DCB *)0xdeadbeef; /*< prevent new uses of DCB */ + backend_ref[i].bref_dcb = NULL; /*< prevent new uses of DCB */ dcb->func.close(dcb); } } @@ -673,6 +672,11 @@ static void freeSession( for (i=0; irses_nbackends; i++) { + if (backend_ref[i].bref_dcb == NULL) + { + continue; + } + ss_dassert(backend_ref[i].bref_backend->backend_conn_count > 0); atomic_add(&backend_ref[i].bref_backend->backend_conn_count, -1); } spinlock_acquire(&router->lock); @@ -1635,6 +1639,7 @@ static bool select_connect_backend_servers( { if (backend_ref[i].bref_dcb != NULL) { + ss_dassert(backend_ref[i].bref_backend->backend_conn_count > 0); /** disconnect opened connections */ backend_ref[i].bref_dcb->func.close(backend_ref[i].bref_dcb); atomic_add(&backend_ref[i].bref_backend->backend_conn_count, -1);