From b68d51ed3047fe45e270b6d23de615c3f8c4b58b Mon Sep 17 00:00:00 2001
From: Subv <subv2112@gmail.com>
Date: Sun, 11 Jan 2015 13:18:52 -0500
Subject: [PATCH] Thread: Prevent waking a thread multiple times.

If a thread was woken up by something, cancel the wakeup timeout.
---
 src/core/hle/kernel/thread.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 0ae1a21df..6d126099b 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -263,6 +263,9 @@ void WakeThreadAfterDelay(Thread* thread, s64 nanoseconds) {
 
 /// Resumes a thread from waiting by marking it as "ready"
 void Thread::ResumeFromWait() {
+    // Cancel any outstanding wakeup events
+    CoreTiming::UnscheduleEvent(ThreadWakeupEventType, GetHandle());
+
     status &= ~THREADSTATUS_WAIT;
     wait_object = nullptr;
     wait_type = WAITTYPE_NONE;