summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-10-01 09:11:35 -0400
committerRich Felker <dalias@aerifal.cx>2011-10-01 09:11:35 -0400
commitb85fec2ded3f005b877e25b63215c0d09d4a9f7f (patch)
treea990adab7dd2668c7d2b34bd6ef53056c21be309
parent8b98c09f8c6a0c366f06b7e6a4b3555a07e5244d (diff)
downloadmusl-b85fec2ded3f005b877e25b63215c0d09d4a9f7f.tar.gz
fix failure-to-wake in rwlock unlock
a reader unlocking the lock need only wake one waiter (necessarily a writer, but a writer unlocking the lock must wake all waiters (necessarily readers). if it only wakes one, the remainder can remain blocked indefinitely, or at least until the first reader unlocks (in which case the whole lock becomes serialized and behaves as a mutex rather than a read lock).
-rw-r--r--src/thread/pthread_rwlock_unlock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/thread/pthread_rwlock_unlock.c b/src/thread/pthread_rwlock_unlock.c
index 5edca634..a6d20854 100644
--- a/src/thread/pthread_rwlock_unlock.c
+++ b/src/thread/pthread_rwlock_unlock.c
@@ -12,7 +12,7 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rw)
} while (a_cas(&rw->_rw_lock, val, new) != val);
if (!new && (waiters || val<0))
- __wake(&rw->_rw_lock, 1, 0);
+ __wake(&rw->_rw_lock, cnt, 0);
return 0;
}