diff options
author | Torvald Riegel <triegel@redhat.com> | 2015-04-28 23:24:36 +0200 |
---|---|---|
committer | Torvald Riegel <triegel@redhat.com> | 2015-06-04 15:34:30 +0200 |
commit | b634486d57a14b53f1cfcf739e41ddf826e51977 (patch) | |
tree | 65ad6788da14adc8effdd9d1b4236ac24af710d7 /nptl/pthread_rwlock_unlock.c | |
parent | 3c9c61febede148b79d8509e16588152d99b3774 (diff) | |
download | glibc-b634486d57a14b53f1cfcf739e41ddf826e51977.tar.gz glibc-b634486d57a14b53f1cfcf739e41ddf826e51977.tar.xz glibc-b634486d57a14b53f1cfcf739e41ddf826e51977.zip |
Fix missing wake-ups in pthread_rwlock_rdlock.
This adds wake-ups that would be missing if assuming that for a non-writer-preferring rwlock, if one thread has acquired a rdlock and does not release it, another thread will eventually acquire a rdlock too despite concurrent write lock acquisition attempts. BZ 14958 is about supporting this assumption. Strictly speaking, this isn't a valid test case, but nonetheless worth supporting (see comment 7 of BZ 14958).
Diffstat (limited to 'nptl/pthread_rwlock_unlock.c')
-rw-r--r-- | nptl/pthread_rwlock_unlock.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/nptl/pthread_rwlock_unlock.c b/nptl/pthread_rwlock_unlock.c index b8336f62bf..d2ad4b0375 100644 --- a/nptl/pthread_rwlock_unlock.c +++ b/nptl/pthread_rwlock_unlock.c @@ -40,8 +40,13 @@ __pthread_rwlock_unlock (pthread_rwlock_t *rwlock) rwlock->__data.__writer = 0; else --rwlock->__data.__nr_readers; + /* If there are still readers present, we do not yet need to wake writers + nor are responsible to wake any readers. */ if (rwlock->__data.__nr_readers == 0) { + /* Note that if there is a blocked writer, we effectively make it + responsible for waking any readers because we don't wake readers in + this case. */ if (rwlock->__data.__nr_writers_queued) { ++rwlock->__data.__writer_wakeup; |