From 2963d10325bb1b967350da64d73c19ab62c98426 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Thu, 8 May 2025 08:21:43 +0200 Subject: [PATCH] cellSysutilCheckCallback: increase read_counter as soon as a callback is about to be called The game might call sys_process_exit in one of the callbacks. This might take a couple of seconds and does not increase the counter. So we have to increase it before in order to give Kill some more time. --- rpcs3/Emu/Cell/Modules/cellSysutil.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp index a236398598..a7d15af2d5 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutil.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutil.cpp @@ -580,8 +580,6 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu) auto& cbm = g_fxo->get(); - bool read = false; - for (auto&& func : cbm.registered.pop_all()) { if (func.call_active && !*func.call_active) @@ -589,7 +587,11 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu) continue; } - read = true; + // Increase read counter before we call the callback. + // We use this counter to check if the game reacts to a command during game termination and calls sys_process_exit. + // We would not realize that the game reacted in time and terminate it prematurely if we increased + // the counter after we called the callback and the callback did some time-consuming work. + cbm.read_counter++; if (s32 res = func.func(ppu)) { @@ -603,11 +605,6 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu) } } - if (read) - { - cbm.read_counter++; - } - return CELL_OK; }