From 798b7733934b2150a65f32c5637603abc8f1de6b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Fri, 4 Aug 2023 15:16:13 -0400 Subject: [PATCH] kernel/user_mutex: Fix unset of locked flag if no entries were notified. It turns out this code actually is possible to trigger, e.g. using Git checkouts, where EINTR due to signals happens quite often. However, even with this commit, it still does not work quite right, due to an oversight in condition-variable notify accounting. That will be addressed in the next commit. --- src/system/kernel/locks/user_mutex.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/kernel/locks/user_mutex.cpp b/src/system/kernel/locks/user_mutex.cpp index bfb4671c92..37a807a2ef 100644 --- a/src/system/kernel/locks/user_mutex.cpp +++ b/src/system/kernel/locks/user_mutex.cpp @@ -406,7 +406,7 @@ user_mutex_unblock(UserMutexEntry* entry, int32* mutex, uint32 flags, bool isWir entry->condition.NotifyAll(B_OK); } else { if (!entry->condition.NotifyOne(B_OK)) - user_atomic_or(mutex, ~(int32)B_USER_MUTEX_LOCKED, isWired); + user_atomic_and(mutex, ~(int32)B_USER_MUTEX_LOCKED, isWired); } if (entry->condition.EntriesCount() == 0)