Skip to content

Commit

Permalink
Fix memory orderings on rwlock upgrade.
Browse files Browse the repository at this point in the history
Fixes #294
  • Loading branch information
Amanieu committed Aug 25, 2021
1 parent 6bbf522 commit c866ba8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/raw_rwlock.rs
Expand Up @@ -362,7 +362,7 @@ unsafe impl lock_api::RawRwLockUpgrade for RawRwLock {
unsafe fn upgrade(&self) {
let state = self.state.fetch_sub(
(ONE_READER | UPGRADABLE_BIT) - WRITER_BIT,
Ordering::Relaxed,
Ordering::Acquire,
);
if state & READERS_MASK != ONE_READER {
let result = self.upgrade_slow(None);
Expand All @@ -377,7 +377,7 @@ unsafe impl lock_api::RawRwLockUpgrade for RawRwLock {
.compare_exchange_weak(
ONE_READER | UPGRADABLE_BIT,
WRITER_BIT,
Ordering::Relaxed,
Ordering::Acquire,
Ordering::Relaxed,
)
.is_ok()
Expand Down

0 comments on commit c866ba8

Please sign in to comment.