Remove some contention on the DCB zombie queue spinlock

A fix for final free beign called when a DCB has not yet had a session created
This commit is contained in:
Mark Riddoch 2013-09-05 22:05:55 +02:00
parent 66e9be814b
commit 0d47aa2d3a

View File

@ -161,6 +161,7 @@ dcb_add_to_zombieslist(DCB *dcb)
if (dcb->state == DCB_STATE_ZOMBIE)
{
ss_dassert(zombies != NULL);
spinlock_release(&zombiespin);
return;
}
@ -215,7 +216,7 @@ dcb_add_to_zombieslist(DCB *dcb)
static void
dcb_final_free(DCB *dcb)
{
SERVICE *service;
SERVICE *service = NULL;
CHK_DCB(dcb);
ss_info_dassert(dcb->state == DCB_STATE_DISCONNECTED,
@ -249,7 +250,8 @@ SERVICE *service;
/**
* Terminate router session.
*/
service = dcb->session->service;
if (dcb->session)
service = dcb->session->service;
if (service != NULL &&
service->router != NULL &&
@ -320,6 +322,16 @@ DCB* dcb_list = NULL;
DCB* dcb = NULL;
bool succp = false;
/*
* Perform a dirty read to see if there is anything in the queue.
* This avoids threads hitting the queue spinlock when the queue
* is empty. This will really help when the only entry is being
* freed, since the queue is updated before the expensive call to
* dcb_final_free.
*/
if (!zombies)
return;
spinlock_acquire(&zombiespin);
ptr = zombies;
lptr = NULL;