Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RawRwLock::wait_for_readers needs an Acquire to synchronize with unlock_shared #260

Merged
merged 1 commit into from Nov 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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