Commit 1c320bc9 authored by Robin Cheng's avatar Robin Cheng Committed by Facebook GitHub Bot

Fix a memory ordering issue in Baton::timedWaitThread.

Summary: The memory ordering when loading the `waiter_` atomic must be at least memory_order_acquire to ensure that anything sequenced after timedWaitThread happens before the corresponding post call. In fact, this is already the memory ordering used in the non-timed version Baton::waitThread.

Differential Revision: D22901656

fbshipit-source-id: 8e8156bdfda02d6b26565b91054ef3cc59a28e8a
parent 55917d46
...@@ -87,7 +87,7 @@ bool Baton::timedWaitThread( ...@@ -87,7 +87,7 @@ bool Baton::timedWaitThread(
if (wait_rv == folly::detail::FutexResult::TIMEDOUT) { if (wait_rv == folly::detail::FutexResult::TIMEDOUT) {
return false; return false;
} }
waiter = waiter_.load(std::memory_order_relaxed); waiter = waiter_.load(std::memory_order_acquire);
} while (waiter == THREAD_WAITING); } while (waiter == THREAD_WAITING);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment