Protection against double entry on the zombie queue

This commit is contained in:
Mark Riddoch 2013-07-23 14:33:50 +02:00
parent 6ed63b12d4
commit 8cb1072d34

View File

@ -124,6 +124,12 @@ DCB *rval;
void
dcb_free(DCB *dcb)
{
if (dcb->state == DCB_STATE_ZOMBIE)
{
skygw_log_write(NULL, LOGFILE_ERROR, "Call to free a DCB that is already a zombie.\n");
return;
}
/* Set the bitmask of running pollng threads */
bitmask_copy(&dcb->memdata.bitmask, poll_bitmask());
@ -135,8 +141,17 @@ dcb_free(DCB *dcb)
{
DCB *ptr = zombies;
while (ptr->memdata.next)
{
if (ptr == dcb)
{
skygw_log_write(NULL, LOGFILE_ERROR, "Attempt to add DCB to zombie queue "
"when it is already in the queue");
break;
}
ptr = ptr->memdata.next;
ptr->memdata.next = dcb;
}
if (ptr != dcb)
ptr->memdata.next = dcb;
}
spinlock_release(&zombiespin);