From d29c0e6ee560b3e1aac5163925b2630cb28ebf99 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 16 Sep 2024 15:38:29 -0400 Subject: [PATCH] libroot: Fix shared unnamed semaphore acquisition with timeouts. We set flags above the timeout check, so we need to use |= and not lose the SHARED flag we already set. Fixes some testcases in the POSIX testsuite, and the shared semaphore code in Gecko/Firefox. --- src/system/libroot/posix/semaphore.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/libroot/posix/semaphore.cpp b/src/system/libroot/posix/semaphore.cpp index ee3c1e256a..aeb3e0e474 100644 --- a/src/system/libroot/posix/semaphore.cpp +++ b/src/system/libroot/posix/semaphore.cpp @@ -176,10 +176,10 @@ unnamed_sem_timedwait(sem_t* semaphore, clockid_t clock_id, timeoutMicros = -1; switch (clock_id) { case CLOCK_REALTIME: - flags = B_ABSOLUTE_REAL_TIME_TIMEOUT; + flags |= B_ABSOLUTE_REAL_TIME_TIMEOUT; break; case CLOCK_MONOTONIC: - flags = B_ABSOLUTE_TIMEOUT; + flags |= B_ABSOLUTE_TIMEOUT; break; default: return EINVAL;