Skip to content

Commit

Permalink
Auto merge of #35378 - Amanieu:rwlock_eagain, r=alexcrichton
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors authored Aug 7, 2016
2 parents ddf92ff + dff62c1 commit 877dfeb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libstd/sys/unix/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 877dfeb

Please sign in to comment.