From 406907d57055965780e04769482556995de8c50a Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 10 Dec 2016 13:29:31 -0500 Subject: Properly remove a thread from its wait_objects' waitlist when it is awoken by a timeout. --- src/core/hle/kernel/kernel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/core/hle/kernel/kernel.cpp') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 653697843..2ddeffcdd 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -38,6 +38,11 @@ SharedPtr WaitObject::GetHighestPriorityReadyThread() { return thread->status == THREADSTATUS_RUNNING || thread->status == THREADSTATUS_READY; }); + // TODO(Subv): This call should be performed inside the loop below to check if an object can be + // acquired by a particular thread. This is useful for things like recursive locking of Mutexes. + if (ShouldWait()) + return nullptr; + Thread* candidate = nullptr; s32 candidate_priority = THREADPRIO_LOWEST + 1; @@ -67,7 +72,7 @@ void WaitObject::WakeupAllWaitingThreads() { thread->wait_set_output = false; } } else { - for (auto object : thread->wait_objects) { + for (auto& object : thread->wait_objects) { object->Acquire(); object->RemoveWaitingThread(thread.get()); } -- cgit v1.2.3