From 630213afb66f720368d68878f0b8616dd8e19db7 Mon Sep 17 00:00:00 2001 From: Ivan Chikish Date: Sun, 23 Jul 2023 06:01:56 +0300 Subject: [PATCH] Fixup shared_mutex::lock_forced --- orbis-kernel/src/utils/SharedMutex.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/orbis-kernel/src/utils/SharedMutex.cpp b/orbis-kernel/src/utils/SharedMutex.cpp index 00177a341..1aa78f3a1 100644 --- a/orbis-kernel/src/utils/SharedMutex.cpp +++ b/orbis-kernel/src/utils/SharedMutex.cpp @@ -152,7 +152,7 @@ void shared_mutex::impl_lock_upgrade() { } bool shared_mutex::lock_forced(int count) { if (count == 0) - std::abort(); + return false; if (count > 0) { // Lock return atomic_op(m_value, [&](unsigned &v) { @@ -172,12 +172,8 @@ bool shared_mutex::lock_forced(int count) { }); } - // Unlock - const unsigned value = m_value.fetch_add(c_one * count); - if (value != c_one) [[unlikely]] { - impl_unlock(value); - } - - return false; + // Remove waiters + m_value.fetch_add(c_one * count); + return true; } } // namespace orbis::utils