Mutex: Release all held mutexes when a thread exits.

This commit is contained in:
Subv 2014-12-07 15:44:21 -05:00
parent e3c8e4901c
commit 64128aa61a
3 changed files with 56 additions and 22 deletions

View file

@ -14,6 +14,7 @@
#include "core/hle/hle.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/result.h"
#include "core/mem_map.h"
@ -156,6 +157,9 @@ ResultCode StopThread(Handle handle, const char* reason) {
Thread* thread = g_object_pool.Get<Thread>(handle);
if (thread == nullptr) return InvalidHandle(ErrorModule::Kernel);
// Release all the mutexes that this thread holds
ReleaseThreadMutexes(handle);
ChangeReadyState(thread, false);
thread->status = THREADSTATUS_DORMANT;
for (Handle waiting_handle : thread->waiting_threads) {