fix deadlock in condition wait whenever there are multiple waiters

it's amazing none of the conformance tests i've run even bothered to
check whether something so basic works...
This commit is contained in:
Rich Felker
2011-09-22 21:08:55 -04:00
parent 2eff02e4a0
commit 4b153ac424
4 changed files with 18 additions and 5 deletions

View File

@ -2,7 +2,8 @@
int pthread_cond_broadcast(pthread_cond_t *c)
{
if (a_swap(&c->_c_block, 0))
int w = c->_c_waiters;
if (a_swap(&c->_c_block, 0) || w)
__wake(&c->_c_block, -1, 0);
return 0;
}