From adeb8793c21e8128ef50ecb555663dfa7ea9fda6 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 9 Jun 2018 22:41:07 -0300 Subject: [PATCH] Fix a thread sync bug as is the usual... --- Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs index 70107c3afc..12bc657a6c 100644 --- a/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs +++ b/Ryujinx.Core/OsHle/Kernel/SvcThreadSync.cs @@ -254,7 +254,7 @@ namespace Ryujinx.Core.OsHle.Kernel WaitThread.MutexAddress = MutexAddress; WaitThread.CondVarAddress = CondVarAddress; - lock (Process.ThreadArbiterList) + lock (Process.ThreadSyncLock) { WaitThread.CondVarSignaled = false; @@ -267,12 +267,18 @@ namespace Ryujinx.Core.OsHle.Kernel { Process.Scheduler.EnterWait(WaitThread, NsTimeConverter.GetTimeMs(Timeout)); - lock (Process.ThreadArbiterList) + lock (Process.ThreadSyncLock) { - if (!WaitThread.CondVarSignaled) + WaitThread.MutexOwner?.MutexWaiters.Remove(WaitThread); + + if (!WaitThread.CondVarSignaled || WaitThread.MutexOwner != null) { + WaitThread.MutexOwner = null; + Process.ThreadArbiterList.Remove(WaitThread); + Ns.Log.PrintDebug(LogClass.KernelSvc, "Timed out..."); + return false; } } @@ -287,7 +293,7 @@ namespace Ryujinx.Core.OsHle.Kernel private void CondVarSignal(KThread CurrThread, long CondVarAddress, int Count) { - lock (Process.ThreadArbiterList) + lock (Process.ThreadSyncLock) { while (Count == -1 || Count-- > 0) {