From 17ec98fa3d2689b7e82b823d02aca16c24ebf9de Mon Sep 17 00:00:00 2001 From: vraatikka Date: Thu, 5 Sep 2013 19:47:42 +0300 Subject: [PATCH] session was assigned state SESSION_STATE_READY outside protected block, and backend dcb thread saw authentication data and session in SESSION_STATE_ALLOC state, which trapped. Moved state assignment inside protection block. --- server/core/session.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/core/session.c b/server/core/session.c index 83a036c86..4b59ab26b 100644 --- a/server/core/session.c +++ b/server/core/session.c @@ -101,6 +101,9 @@ session_alloc(SERVICE *service, DCB *client) session->data = client->data; client->session = session; session->refcount = 1; + /** This indicates that session is ready to be shared with backend DCBs. */ + session->state = SESSION_STATE_READY; + /** Release session lock */ spinlock_release(&session->ses_lock); @@ -123,10 +126,6 @@ session_alloc(SERVICE *service, DCB *client) session->next = allSessions; allSessions = session; spinlock_release(&session_spin); - - /** This indicates that session is ready to be shared with backend DCBs. */ - session->state = SESSION_STATE_READY; - atomic_add(&service->stats.n_sessions, 1); atomic_add(&service->stats.n_current, 1); CHK_SESSION(session); @@ -144,6 +143,9 @@ bool session_link_dcb(SESSION *session, DCB *dcb) { spinlock_acquire(&session->ses_lock); + ss_info_dassert(session->state != SESSION_STATE_FREE, + "If session->state is SESSION_STATE_FREE then this attempt to " + "access freed memory block."); if (session->state == SESSION_STATE_FREE) { spinlock_release(&session->ses_lock);