diff --git a/src/libstd/sys/unix/rwlock.rs b/src/libstd/sys/unix/rwlock.rs index c754d5b8359a..8c385ae7760a 100644 --- a/src/libstd/sys/unix/rwlock.rs +++ b/src/libstd/sys/unix/rwlock.rs @@ -14,7 +14,7 @@ use sync::atomic::{AtomicUsize, Ordering}; pub struct RWLock { inner: UnsafeCell, - write_locked: UnsafeCell, + write_locked: UnsafeCell, // guarded by the `inner` RwLock num_readers: AtomicUsize, } @@ -52,7 +52,7 @@ impl RWLock { // allow that because it could lead to aliasing issues. if r == libc::EAGAIN { panic!("rwlock maximum reader count exceeded"); - } else if r == libc::EDEADLK || *self.write_locked.get() { + } else if r == libc::EDEADLK || (r == 0 && *self.write_locked.get()) { if r == 0 { self.raw_unlock(); }