From 17b9298d9918a36c344741f20f165bc67b5b7769 Mon Sep 17 00:00:00 2001 From: rpj Date: Thu, 27 May 1999 20:44:42 +0000 Subject: Fri May 28 13:33:05 1999 Ross Johnson * condvar.c (pthread_cond_broadcast): Fix possible memory fault - Mark E. Armstrong Thu May 27 13:08:46 1999 Ross Johnson * condvar.c (pthread_cond_broadcast): Fix logic bug - Peter Slacik ; optimise sem_post loop - Bossom, John . --- ChangeLog | 15 ++++++++++++++- condvar.c | 13 ++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0eee706..ddfb3ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,19 @@ +Fri May 28 13:33:05 1999 Ross Johnson + + * condvar.c (pthread_cond_broadcast): Fix possible memory fault + - Mark E. Armstrong + +Thu May 27 13:08:46 1999 Ross Johnson + + * condvar.c (pthread_cond_broadcast): Fix logic bug + - Peter Slacik ; + optimise sem_post loop + - Bossom, John . + Fri May 14 12:13:18 1999 Ross Johnson - * attr.c (pthread_attr_setdetachstate): Fix logic bug. + * attr.c (pthread_attr_setdetachstate): Fix logic bug + - Mike Russo . Wed Apr 7 14:09:52 1999 Ross Johnson diff --git a/condvar.c b/condvar.c index a77b56a..c1f192c 100644 --- a/condvar.c +++ b/condvar.c @@ -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; -- cgit v1.2.3