Skip to content

Commit fd7cbfa

Browse files
authored
Merge pull request #70761 from al45tair/eng/PR-119739594
[Threading] Fix C11 once implementation to not rely on lock recursion.
2 parents e2d2ca0 + 0b4ea77 commit fd7cbfa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Threading/C11.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class C11ThreadingHelper {
4343
void once_unlock() { SWIFT_C11THREADS_CHECK(mtx_unlock(&onceMutex_)); }
4444
void once_broadcast() { SWIFT_C11THREADS_CHECK(cnd_broadcast(&onceCond_)); }
4545
void once_wait() {
46-
SWIFT_C11THREADS_CHECK(mtx_lock(&onceMutex_));
46+
// The mutex must be locked when this function is entered. It will
47+
// be locked again before the function returns.
4748
SWIFT_C11THREADS_CHECK(cnd_wait(&onceCond_, &onceMutex_));
48-
SWIFT_C11THREADS_CHECK(mtx_unlock(&onceMutex_));
4949
}
5050
};
5151

0 commit comments

Comments
 (0)