From feff2ba09e3b4bba230e90e968304f87590fac43 Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Thu, 13 Jun 2024 21:06:12 +0200 Subject: [PATCH] Fix race in sys_net select and poll --- rpcs3/Emu/Cell/lv2/sys_net.cpp | 16 ++-------------- rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp | 2 +- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index abc4296033..56b58f407b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -1412,14 +1412,8 @@ error_code sys_net_bnet_poll(ppu_thread& ppu, vm::ptr fds, s32 n return {}; } - std::lock_guard nw_lock(g_fxo->get().mutex_thread_loop); - - if (signaled) - { - break; - } - has_timedout = network_clear_queue(ppu); + ppu.state -= cpu_flag::signal; break; } } @@ -1651,14 +1645,8 @@ error_code sys_net_bnet_select(ppu_thread& ppu, s32 nfds, vm::ptrget().mutex_thread_loop); - - if (signaled) - { - break; - } - has_timedout = network_clear_queue(ppu); + ppu.state -= cpu_flag::signal; break; } } diff --git a/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp b/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp index c4c79680b3..72356c54e1 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net/network_context.cpp @@ -96,9 +96,9 @@ void base_network_thread::wake_threads() if (!ppu_to_awake.empty()) { + ppu_to_awake.clear(); lv2_obj::awake_all(); } - ppu_to_awake.clear(); } p2p_thread::p2p_thread()