From d84b4adc831037137ad7da211be3ef17a83e9819 Mon Sep 17 00:00:00 2001 From: TheTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:18:18 +0300 Subject: [PATCH] semaphore: Yet another race condition fix (#327) --- src/core/libraries/kernel/threads/semaphore.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/libraries/kernel/threads/semaphore.cpp b/src/core/libraries/kernel/threads/semaphore.cpp index bfa6a68d..370dba44 100644 --- a/src/core/libraries/kernel/threads/semaphore.cpp +++ b/src/core/libraries/kernel/threads/semaphore.cpp @@ -41,7 +41,6 @@ public: AddWaiter(waiter); // Perform the wait. - std::exchange(lk, std::unique_lock{waiter.mutex}); return waiter.Wait(lk, timeout); } @@ -59,10 +58,9 @@ public: it++; continue; } - std::scoped_lock lk2{waiter.mutex}; + it = wait_list.erase(it); token_count -= waiter.need_count; waiter.cv.notify_one(); - it = wait_list.erase(it); } return true; @@ -84,7 +82,6 @@ public: public: struct WaitingThread : public ListBaseHook { - std::mutex mutex; std::string name; std::condition_variable cv; u32 priority;