Auto merge of #35378 - Amanieu:rwlock_eagain, r=alexcrichton

Handle RwLock reader count overflow

`pthread_rwlock_rdlock` may return `EAGAIN` if the maximum reader count overflows. We shouldn't return a successful lock in that case.
This commit is contained in:
bors 2016-08-06 19:50:48 -07:00 committed by GitHub
commit 877dfeb572

View File

@ -50,7 +50,9 @@ impl RWLock {
// the implementation allows recursive locking. The POSIX standard
// doesn't require recursivly locking a rwlock to deadlock, but we can't
// allow that because it could lead to aliasing issues.
if r == libc::EDEADLK || *self.write_locked.get() {
if r == libc::EAGAIN {
panic!("rwlock maximum reader count exceeded");
} else if r == libc::EDEADLK || *self.write_locked.get() {
if r == 0 {
self.raw_unlock();
}