Skip to content

Commit

Permalink
RawRwLock::wait_for_readers needs an Acquire to synchronize with unlo…
Browse files Browse the repository at this point in the history
…ck_shared

Fixes #257
  • Loading branch information
Amanieu committed Nov 8, 2020
1 parent ecfe20b commit ded782f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/raw_rwlock.rs
Expand Up @@ -970,11 +970,11 @@ impl RawRwLock {
// At this point WRITER_BIT is already set, we just need to wait for the
// remaining readers to exit the lock.
let mut spinwait = SpinWait::new();
let mut state = self.state.load(Ordering::Relaxed);
let mut state = self.state.load(Ordering::Acquire);
while state & READERS_MASK != 0 {
// Spin a few times to wait for readers to exit
if spinwait.spin() {
state = self.state.load(Ordering::Relaxed);
state = self.state.load(Ordering::Acquire);
continue;
}

Expand Down Expand Up @@ -1019,7 +1019,7 @@ impl RawRwLock {
// since a previous writer timing-out could have allowed
// another reader to sneak in before we parked.
ParkResult::Unparked(_) | ParkResult::Invalid => {
state = self.state.load(Ordering::Relaxed);
state = self.state.load(Ordering::Acquire);
continue;
}

Expand Down

0 comments on commit ded782f

Please sign in to comment.