Skip to content

Commit d58e4f2

Browse files
connortsui20joboet
andcommitted
fix DOWNGRADED bit unpreserved
Co-authored-by: Jonas Böttiger <[email protected]>
1 parent 5d68316 commit d58e4f2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

std/src/sync/rwlock/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ fn test_downgrade_atomic() {
558558
// modify the protected value.
559559

560560
// `W` is the number of evil writer threads.
561-
const W: usize = if cfg!(target_pointer_width = "64") { 100 } else { 20 };
561+
const W: usize = 20;
562562
let rwlock = Arc::new(RwLock::new(0));
563563

564564
// Spawns many evil writer threads that will try and write to the locked value before the

std/src/sys/sync/rwlock/queue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ impl RwLock {
395395
node.next.0 = AtomicPtr::new(state.mask(NODE_MASK).cast());
396396
node.prev = AtomicLink::new(None);
397397

398-
// Set the `QUEUED` bit and maintain the `LOCKED` bit.
398+
// Set the `QUEUED` bit and preserve the `LOCKED` and `DOWNGRADED` bit.
399399
let mut next = ptr::from_ref(&node)
400-
.map_addr(|addr| addr | QUEUED | (state.addr() & LOCKED))
400+
.map_addr(|addr| addr | QUEUED | (state.addr() & (DOWNGRADED | LOCKED)))
401401
as State;
402402

403403
let mut is_queue_locked = false;

0 commit comments

Comments
 (0)