Bugzilla bug #32779: PR_Interrupt should increment the cv's

pending_notify count before broadcasting on the cv to prevent
the interrupted thread from destroying the cv before
pthread_cond_broadcast returns.
This commit is contained in:
wtc%netscape.com 2000-03-22 18:47:54 +00:00
Родитель 74ccfe056f
Коммит 20725ce270
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -654,8 +654,12 @@ PR_IMPLEMENT(PRStatus) PR_Interrupt(PRThread *thred)
cv = thred->waiting; cv = thred->waiting;
if ((NULL != cv) && !thred->interrupt_blocked) if ((NULL != cv) && !thred->interrupt_blocked)
{ {
PRIntn rv = pthread_cond_broadcast(&cv->cv); PRIntn rv;
(void)PR_AtomicIncrement(&cv->notify_pending);
rv = pthread_cond_broadcast(&cv->cv);
PR_ASSERT(0 == rv); PR_ASSERT(0 == rv);
if (0 > PR_AtomicDecrement(&cv->notify_pending))
PR_DestroyCondVar(cv);
} }
return PR_SUCCESS; return PR_SUCCESS;
} /* PR_Interrupt */ } /* PR_Interrupt */