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.
This commit is contained in:
Megamouse 2025-05-08 08:21:43 +02:00
parent 501643c10a
commit 2963d10325

View file

@ -580,8 +580,6 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu)
auto& cbm = g_fxo->get<sysutil_cb_manager>();
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;
}