From eb22f6bb78bbac7b8523e51641c049dc083337e6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 13 Dec 2012 23:05:26 -0800 Subject: [PATCH] Wake threads when an event flag is deleted. --- Core/HLE/sceKernelEventFlag.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelEventFlag.cpp b/Core/HLE/sceKernelEventFlag.cpp index c1a9de550f..92f96fc5f0 100644 --- a/Core/HLE/sceKernelEventFlag.cpp +++ b/Core/HLE/sceKernelEventFlag.cpp @@ -158,7 +158,29 @@ u32 sceKernelClearEventFlag(SceUID id, u32 bits) u32 sceKernelDeleteEventFlag(SceUID uid) { DEBUG_LOG(HLE,"sceKernelDeleteEventFlag(%i)", uid); - return kernelObjects.Destroy(uid); + + u32 error; + EventFlag *e = kernelObjects.Get(uid, error); + if (e) + { + bool wokeThreads = false; + std::vector::iterator iter, end; + for (iter = e->waitingThreads.begin(), end = e->waitingThreads.end(); iter != end; ++iter) + { + // TODO: timeoutPtr, outPtr? Check still waiting. + __KernelResumeThreadFromWait(iter->tid, SCE_KERNEL_ERROR_WAIT_DELETE); + wokeThreads = true; + } + + e->waitingThreads.clear(); + + if (wokeThreads) + hleReSchedule("event flag deleted"); + + return kernelObjects.Destroy(uid); + } + else + return error; } u8 __KernelEventFlagMatches(u32 *pattern, u32 bits, u8 wait, u32 outAddr)