diff options
author | rpj <rpj> | 1999-05-27 20:44:42 +0000 |
---|---|---|
committer | rpj <rpj> | 1999-05-27 20:44:42 +0000 |
commit | 17b9298d9918a36c344741f20f165bc67b5b7769 (patch) | |
tree | 047d35b87fc2ad8c1a7716f163ff4d50867d7966 /condvar.c | |
parent | 67f6e902524b3f59d7de7bf8e3574ff7a7911028 (diff) |
Fri May 28 13:33:05 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* condvar.c (pthread_cond_broadcast): Fix possible memory fault
- Mark E. Armstrong <avail@pacbell.net>
Thu May 27 13:08:46 1999 Ross Johnson <rpj@swan.canberra.edu.au>
* condvar.c (pthread_cond_broadcast): Fix logic bug
- Peter Slacik <Peter.Slacik@tatramed.sk>;
optimise sem_post loop
- Bossom, John <John.Bossom@Cognos.COM>.
Diffstat (limited to 'condvar.c')
-rw-r--r-- | condvar.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -827,8 +827,6 @@ pthread_cond_broadcast (pthread_cond_t * cond) cv = *cond; - cv->wasBroadcast = TRUE; - /* * No-op if the CV is static and hasn't been initialised yet. */ @@ -837,13 +835,14 @@ pthread_cond_broadcast (pthread_cond_t * cond) return 0; } + cv->wasBroadcast = TRUE; + /* * Wake up all waiters */ - for (i = cv->waiters; i > 0 && result == 0; i--) - { - result = sem_post (&(cv->sema)); - } + result = (ReleaseSemaphore( cv->sema, cond->waiters, NULL ) + ? 0 + : EINVAL); if (cv->waiters > 0 && result == 0) { @@ -851,7 +850,7 @@ pthread_cond_broadcast (pthread_cond_t * cond) * Wait for all the awakened threads to acquire their part of * the counting semaphore */ - if (WaitForSingleObject (cv->waitersDone, INFINITE) != + if (WaitForSingleObject (cv->waitersDone, INFINITE) == WAIT_OBJECT_0) { result = 0; |