From 40e09cc526296030ba87afbf5f77f3c16a9a9f0f Mon Sep 17 00:00:00 2001 From: eladash Date: Tue, 26 Mar 2019 21:08:49 +0200 Subject: [PATCH] Fix timer state after event queue was destroyed * Hw tests show state is unaffected by external destruction of the event queue * Minor race regarding state check fixed (can result in an undestroyable state) --- rpcs3/Emu/Cell/lv2/sys_timer.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_timer.cpp b/rpcs3/Emu/Cell/lv2/sys_timer.cpp index 755f42cbe71f..8f27d2f3546b 100644 --- a/rpcs3/Emu/Cell/lv2/sys_timer.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_timer.cpp @@ -1,4 +1,4 @@ -#include "stdafx.h" +#include "stdafx.h" #include "Emu/Memory/vm.h" #include "Emu/System.h" #include "Emu/IdManager.h" @@ -33,17 +33,17 @@ void lv2_timer_context::operator()() if (const auto queue = port.lock()) { queue->send(source, data1, data2, next); + } - if (period) - { - // Set next expiration time and check again (HACK) - expire += period; - continue; - } + if (period) + { + // Set next expiration time and check again (HACK) + expire += period; + continue; } - // Stop: oneshot or the event port was disconnected (TODO: is it correct?) - state = SYS_TIMER_STATE_STOP; + // Stop after oneshot + state.compare_and_swap_test(SYS_TIMER_STATE_RUN, SYS_TIMER_STATE_STOP); continue; }