From cec976b70a6c3b1dab87b3dae60e1023e95c940e Mon Sep 17 00:00:00 2001 From: Elad Ashkenazi <18193363+elad335@users.noreply.github.com> Date: Wed, 12 Jun 2024 08:19:50 +0300 Subject: [PATCH] Minor fix of sys_lwmutex_destroy --- rpcs3/Emu/Cell/lv2/sys_lwmutex.h | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h index 73f87965e3..5a97fbae1b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_lwmutex.h +++ b/rpcs3/Emu/Cell/lv2/sys_lwmutex.h @@ -108,30 +108,32 @@ struct lv2_lwmutex final : lv2_obj } }).signaled; - const bool notify = lwcond_waiters.fetch_op([](s32& val) - { - if (val + 0u <= 1u << 31) - { - // Value was either positive or INT32_MIN - return false; - } - - // lwmutex was set to be destroyed, but there are lwcond waiters - // Turn off the "lwcond_waiters notification" bit as we are adding an lwmutex waiter - val &= 0x7fff'ffff; - return true; - }).second; - - if (notify) - { - // Notify lwmutex destroyer (may cause EBUSY to be returned for it) - lwcond_waiters.notify_all(); - } - if (signal) { cpu->next_cpu = nullptr; } + else + { + const bool notify = lwcond_waiters.fetch_op([](s32& val) + { + if (val + 0u <= 1u << 31) + { + // Value was either positive or INT32_MIN + return false; + } + + // lwmutex was set to be destroyed, but there are lwcond waiters + // Turn off the "lwcond_waiters notification" bit as we are adding an lwmutex waiter + val &= 0x7fff'ffff; + return true; + }).second; + + if (notify) + { + // Notify lwmutex destroyer (may cause EBUSY to be returned for it) + lwcond_waiters.notify_all(); + } + } return signal; }