diff options
author | rpj <rpj> | 2004-10-21 08:19:50 +0000 |
---|---|---|
committer | rpj <rpj> | 2004-10-21 08:19:50 +0000 |
commit | 5d4eb88954fa2402dcce06ccecde800da1c8703f (patch) | |
tree | 3362da76a993074e1876ed54f9745d8fbfe65992 | |
parent | da041b8ec0cfb1a70146e7f16459282f518bded6 (diff) |
Mutex logic fix
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pthread_mutex_unlock.c | 9 |
2 files changed, 12 insertions, 2 deletions
@@ -1,3 +1,8 @@ +2004-10-21 Ross Johnson <rpj at callisto.canberra.edu.au>
+ + * pthread_mutex_unlock.c (pthread_mutex_unlock): Must use PulseEvent() + rather than SetEvent() to reset the event if there are no waiters. + 2004-10-19 Ross Johnson <rpj at callisto.canberra.edu.au>
* sem_init.c (sem_init): New semaphore model based on the same idea diff --git a/pthread_mutex_unlock.c b/pthread_mutex_unlock.c index e28b38a..9b8e504 100644 --- a/pthread_mutex_unlock.c +++ b/pthread_mutex_unlock.c @@ -67,8 +67,13 @@ pthread_mutex_unlock (pthread_mutex_t * mutex) { if (idx < 0) { - /* Someone may be waiting on that mutex */ - if (SetEvent (mx->event) == 0) + /* + * Someone may be waiting on that mutex. + * Pulse event on an auto-reset event will + * release one waiter if possible, otherwise + * it will just reset the event. + */ + if (PulseEvent (mx->event) == 0) { result = EINVAL; } |