Index: src/untrusted/pthread/nc_rwlock.c |
diff --git a/src/untrusted/pthread/nc_rwlock.c b/src/untrusted/pthread/nc_rwlock.c |
index a824f02a6b3c4e33429d8b903b07be3b0f0094c1..760f2d5fc422c76533eb9a02fd930bb8fa2cb228 100644 |
--- a/src/untrusted/pthread/nc_rwlock.c |
+++ b/src/untrusted/pthread/nc_rwlock.c |
@@ -13,9 +13,8 @@ |
* in the case of recursive read lock (see read_lock_available)). See: |
* http://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock |
* |
- * The thundering herd problem is avoided by only waking a single |
- * waiter (either a single writer or a single reader) when the |
- * lock is released. |
+ * The thundering herd problem is avoided (at least for waiting writers) |
+ * by only waking a single writer at a time. |
*/ |
#include <errno.h> |
@@ -239,8 +238,11 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) { |
/* Wake a waiting writer if there is one. */ |
rc = pthread_cond_signal(&rwlock->write_possible); |
} else { |
- /* Otherwise wake a waiting reader. */ |
- rc = pthread_cond_signal(&rwlock->read_possible); |
+ /* |
+ * Otherwise wake all waiting readers. All of them should be able |
+ * to make progress now that the write lock is no longer held. |
+ */ |
+ rc = pthread_cond_broadcast(&rwlock->read_possible); |
} |
} else { |
if (rwlock->reader_count == 0) { |