From 7db2e2537fad292edcf18bca6d2301d0661996be Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 18 Aug 2019 16:29:02 +0300 Subject: [PATCH] Don't call lv2_obj::awake_all with empty list Fixup after #5883 --- rpcs3/Emu/Cell/lv2/sys_event.cpp | 5 ++++- rpcs3/Emu/Cell/lv2/sys_event_flag.cpp | 12 +++++++++--- rpcs3/Emu/Cell/lv2/sys_net.cpp | 5 ++++- rpcs3/Emu/Cell/lv2/sys_semaphore.cpp | 9 +++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_event.cpp b/rpcs3/Emu/Cell/lv2/sys_event.cpp index cd2cb3f8ad..afc7fda33d 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event.cpp @@ -179,7 +179,10 @@ error_code sys_event_queue_destroy(ppu_thread& ppu, u32 equeue_id, s32 mode) queue->append(cpu); } - lv2_obj::awake_all(); + if (!queue->sq.empty()) + { + lv2_obj::awake_all(); + } } else { diff --git a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp index 678dbaa588..ec6232fb81 100644 --- a/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_event_flag.cpp @@ -317,8 +317,11 @@ error_code sys_event_flag_set(u32 id, u64 bitptn) return false; }); - flag->sq.erase(tail, flag->sq.end()); - lv2_obj::awake_all(); + if (tail != flag->sq.end()) + { + flag->sq.erase(tail, flag->sq.end()); + lv2_obj::awake_all(); + } } return CELL_OK; @@ -380,7 +383,10 @@ error_code sys_event_flag_cancel(ppu_thread& ppu, u32 id, vm::ptr num) flag->append(thread); } - lv2_obj::awake_all(); + if (value) + { + lv2_obj::awake_all(); + } } if (ppu.test_stopped()) diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 13ef3cd972..8c91b70b8a 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -206,7 +206,10 @@ extern void network_thread_init() lv2_obj::append(ppu); } - lv2_obj::awake_all(); + if (!s_to_awake.empty()) + { + lv2_obj::awake_all(); + } s_to_awake.clear(); socklist.clear(); diff --git a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp index ae02a96703..7e125d4b74 100644 --- a/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_semaphore.cpp @@ -237,12 +237,17 @@ error_code sys_semaphore_post(ppu_thread& ppu, u32 sem_id, s32 count) } // Wake threads - for (s32 i = std::min(-std::min(val, 0), count); i > 0; i--) + const s32 to_awake = std::min(-std::min(val, 0), count); + + for (s32 i = 0; i < to_awake; i++) { sem->append(verify(HERE, sem->schedule(sem->sq, sem->protocol))); } - lv2_obj::awake_all(); + if (to_awake > 0) + { + lv2_obj::awake_all(); + } } return CELL_OK;