From e5b4984a1217ed6ca27ac7f043a645456610c402 Mon Sep 17 00:00:00 2001 From: counterpoint Date: Wed, 27 May 2015 16:56:53 +0100 Subject: [PATCH] Fix bugs. --- server/core/dcb.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/server/core/dcb.c b/server/core/dcb.c index ffd99e0cf..f73f5407d 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -1311,25 +1311,27 @@ dcb_close(DCB *dcb) dcb->session = NULL; spinlock_release(&dcb->server->persistlock); atomic_add(&dcb->server->stats.n_persistent, 1); - spinlock_acquire(&dcb->session->ses_lock); - /** - * If session->state is STOPPING, start closing client session. - * Otherwise only this backend connection is closed. - */ - if (session != NULL && - session->state == SESSION_STATE_STOPPING && - session->client != NULL && - session->client->state == DCB_STATE_POLLING) + if (dcb->session) { - spinlock_release(&session->ses_lock); + spinlock_acquire(&dcb->session->ses_lock); + /** + * If session->state is STOPPING, start closing client session. + * Otherwise only this backend connection is closed. + */ + if (dcb->session->state == SESSION_STATE_STOPPING && + dcb->session->client != NULL && + dcb->session->client->state == DCB_STATE_POLLING) + { + spinlock_release(&dcb->session->ses_lock); - /** Close client DCB */ - dcb_close(session->client); + /** Close client DCB */ + dcb_close(dcb->session->client); + } + else + { + spinlock_release(&dcb->session->ses_lock); + } } - else - { - spinlock_release(&session->ses_lock); - } return; }