In dcb_close read and set dcb->state by holding dcb->writeqlock. This prevents simultaneous calls to closeSession.

This commit is contained in:
vraatikka
2013-08-19 16:38:55 +03:00
parent 05a3978442
commit c119f7b7b8

View File

@ -566,9 +566,17 @@ int saved_errno = 0;
void void
dcb_close(DCB *dcb) dcb_close(DCB *dcb)
{ {
/** protect state check and set */
spinlock_acquire(&dcb->writeqlock);
if (dcb->state == DCB_STATE_DISCONNECTED || dcb->state == DCB_STATE_FREED) {
spinlock_release(&dcb->writeqlock);
return;
}
poll_remove_dcb(dcb); poll_remove_dcb(dcb);
close(dcb->fd); close(dcb->fd);
dcb->state = DCB_STATE_DISCONNECTED; dcb->state = DCB_STATE_DISCONNECTED;
spinlock_release(&dcb->writeqlock);
if (dcb_isclient(dcb)) if (dcb_isclient(dcb))
{ {
@ -766,8 +774,6 @@ void dcb_hashtable_stats(
int total; int total;
int longest; int longest;
int hashsize; int hashsize;
int i;
int j;
total = 0; total = 0;
longest = 0; longest = 0;