Commit 10d27fea authored by Cornel Rat's avatar Cornel Rat Committed by Facebook Github Bot

Remove recursion from TimedMutex to avoid fiber stack overflows

Summary: Under heavy contention, lock will recurse several times. This can lead to fiber stack overflow.

Differential Revision: D14936384

fbshipit-source-id: e934569a9f742859655ba3ea888ebabd4d959651
parent 231d1cff
......@@ -79,16 +79,15 @@ TimedMutex::LockResult TimedMutex::lockHelper(WaitFunc&& waitFunc) {
}
inline void TimedMutex::lock() {
auto result = lockHelper([](MutexWaiter& waiter) {
LockResult result;
do {
result = lockHelper([](MutexWaiter& waiter) {
waiter.baton.wait();
return true;
});
DCHECK(result != LockResult::TIMEOUT);
if (result == LockResult::SUCCESS) {
return;
}
lock();
} while (result != LockResult::SUCCESS);
}
template <typename Rep, typename Period>
......
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