about summary refs log tree commit diff
path: root/library/std/src/sys/sync
diff options
context:
space:
mode:
authorConnor Tsui <87130162+connortsui20@users.noreply.github.com>2024-11-16 12:22:35 -0500
committerConnor Tsui <connor.tsui20@gmail.com>2024-11-16 12:31:14 -0500
commit782b07e1ff4a4f8ecf00d5e030dfead9222d2185 (patch)
tree5f022bdfab0f4130f006356e8258296648e9fca8 /library/std/src/sys/sync
parent84fd95cbedf1e1c1826e378ffc4d1a3d335deff4 (diff)
downloadrust-782b07e1ff4a4f8ecf00d5e030dfead9222d2185.tar.gz
rust-782b07e1ff4a4f8ecf00d5e030dfead9222d2185.zip
fix `DOWNGRADED` bit unpreserved
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
Diffstat (limited to 'library/std/src/sys/sync')
-rw-r--r--library/std/src/sys/sync/rwlock/queue.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sys/sync/rwlock/queue.rs b/library/std/src/sys/sync/rwlock/queue.rs
index c654fca0d6e..51330f8fafe 100644
--- a/library/std/src/sys/sync/rwlock/queue.rs
+++ b/library/std/src/sys/sync/rwlock/queue.rs
@@ -395,9 +395,9 @@ impl RwLock {
             node.next.0 = AtomicPtr::new(state.mask(NODE_MASK).cast());
             node.prev = AtomicLink::new(None);
 
-            // Set the `QUEUED` bit and maintain the `LOCKED` bit.
+            // Set the `QUEUED` bit and preserve the `LOCKED` and `DOWNGRADED` bit.
             let mut next = ptr::from_ref(&node)
-                .map_addr(|addr| addr | QUEUED | (state.addr() & LOCKED))
+                .map_addr(|addr| addr | QUEUED | (state.addr() & (DOWNGRADED | LOCKED)))
                 as State;
 
             let mut is_queue_locked = false;