[libc-commits] [PATCH] D149790: [libc][rpc] Fix the memory ordering in lock.
Jon Chesterfield via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed May 3 15:24:07 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf152796fd3e0: [libc][rpc] Fix the memory ordering in lock. (authored by JonChesterfield).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149790/new/
https://reviews.llvm.org/D149790
Files:
libc/src/__support/RPC/rpc.h
Index: libc/src/__support/RPC/rpc.h
===================================================================
--- libc/src/__support/RPC/rpc.h
+++ libc/src/__support/RPC/rpc.h
@@ -248,6 +248,9 @@
if (lock->fetch_or(1, cpp::MemoryOrder::RELAXED))
return cpp::nullopt;
+ // The mailbox state must be read with the lock held.
+ atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);
+
uint32_t in = inbox->load(cpp::MemoryOrder::RELAXED);
uint32_t out = outbox->load(cpp::MemoryOrder::RELAXED);
@@ -285,6 +288,9 @@
if (lock->fetch_or(1, cpp::MemoryOrder::RELAXED))
return cpp::nullopt;
+ // The mailbox state must be read with the lock held.
+ atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);
+
in = inbox->load(cpp::MemoryOrder::RELAXED);
out = outbox->load(cpp::MemoryOrder::RELAXED);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149790.519282.patch
Type: text/x-patch
Size: 810 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230503/9b334d06/attachment-0001.bin>
More information about the libc-commits
mailing list