From db164be9465fd58f8c4ecdb8ada43a120a2e594b Mon Sep 17 00:00:00 2001 From: Massimiliano Pinto Date: Wed, 4 Sep 2013 10:00:40 +0200 Subject: [PATCH] Added spinlock protection for refcount increase in dcb_connect --- server/core/dcb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/core/dcb.c b/server/core/dcb.c index 610da9cb5..9a86f646f 100644 --- a/server/core/dcb.c +++ b/server/core/dcb.c @@ -314,9 +314,17 @@ int val; return NULL; } memcpy(&(dcb->func), funcs, sizeof(GWPROTOCOL)); - dcb->session = session; - val = atomic_add(&dcb->session->refcount, 1); + /* Adding now the session refcount increase for the backend dcb. + * This operation is protected by the authspinlock. + * This spinlock could be used later in backend + * authentication. + */ + spinlock_acquire(&dcb->authlock); + val = atomic_add(&session->refcount, 1); + dcb->session = session; + spinlock_release(&dcb->authlock); + skygw_log_write( LOGFILE_TRACE, "%lu [dcb_connect] Increased DCB %p session %p refcount to %d.",