diff --git a/Core/HLE/sceKernelMbx.cpp b/Core/HLE/sceKernelMbx.cpp index d4b29079ee..b56751231e 100644 --- a/Core/HLE/sceKernelMbx.cpp +++ b/Core/HLE/sceKernelMbx.cpp @@ -232,9 +232,8 @@ void __KernelMbxTimeout(u64 userdata, int cyclesLate) // So, we need to remember it or we won't be able to mark it DELETE instead later. // TODO: Should numWaitThreads be decreased yet? + __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); } - - __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); } void __KernelWaitMbx(Mbx *m, u32 timeoutPtr) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index b49b777613..921774077b 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -982,9 +982,9 @@ void __KernelVplTimeout(u64 userdata, int cyclesLate) // actually running, it will get a DELETE result instead of a TIMEOUT. // So, we need to remember it or we won't be able to mark it DELETE instead later. vpl->nv.numWaitThreads--; - } - __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + } } void __KernelSetVplTimeout(u32 timeoutPtr) diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 173e5bb88f..04f96a5007 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -400,7 +400,9 @@ void __KernelMutexTimeout(u64 userdata, int cyclesLate) if (timeoutPtr != 0) Memory::Write_U32(0, timeoutPtr); - __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + SceUID mutexID = __KernelGetWaitID(threadID, WAITTYPE_MUTEX, error); + if (mutexID != 0) + __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); // We intentionally don't remove from waitingThreads here yet. // The reason is, if it times out, but what it was waiting on is DELETED prior to it @@ -773,7 +775,9 @@ void __KernelLwMutexTimeout(u64 userdata, int cyclesLate) if (timeoutPtr != 0) Memory::Write_U32(0, timeoutPtr); - __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + SceUID mutexID = __KernelGetWaitID(threadID, WAITTYPE_LWMUTEX, error); + if (mutexID != 0) + __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); // We intentionally don't remove from waitingThreads here yet. // The reason is, if it times out, but what it was waiting on is DELETED prior to it diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index 3f78646ed0..4efdeb7cc7 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -298,9 +298,9 @@ void __KernelSemaTimeout(u64 userdata, int cycleslate) // actually running, it will get a DELETE result instead of a TIMEOUT. // So, we need to remember it or we won't be able to mark it DELETE instead later. s->ns.numWaitThreads--; - } - __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + __KernelResumeThreadFromWait(threadID, SCE_KERNEL_ERROR_WAIT_TIMEOUT); + } } void __KernelSetSemaTimeout(Semaphore *s, u32 timeoutPtr)