summaryrefslogtreecommitdiff
path: root/src/thread/pthread_cond_broadcast.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-09-22 21:08:55 -0400
committerRich Felker <dalias@aerifal.cx>2011-09-22 21:08:55 -0400
commit4b153ac42428447a148e6da543ebe6df017078db (patch)
treed9a5b8035f98b8cec47fc6044e38305ea5cdb91a /src/thread/pthread_cond_broadcast.c
parent2eff02e4a032323a45541c79967638d8c77d79e4 (diff)
downloadmusl-4b153ac42428447a148e6da543ebe6df017078db.tar.gz
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...
Diffstat (limited to 'src/thread/pthread_cond_broadcast.c')
-rw-r--r--src/thread/pthread_cond_broadcast.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/thread/pthread_cond_broadcast.c b/src/thread/pthread_cond_broadcast.c
index 30f7f6df..6002c535 100644
--- a/src/thread/pthread_cond_broadcast.c
+++ b/src/thread/pthread_cond_broadcast.c
@@ -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;
}