Check that the mutex address matches before waking a waiting thread
This commit is contained in:
parent
3fae7e30e7
commit
babfcde885
1 changed files with 30 additions and 18 deletions
|
@ -187,8 +187,17 @@ namespace Ryujinx.Core.OsHle.Kernel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock (CurrThread)
|
||||||
|
{
|
||||||
|
//This is the new thread that will not own the mutex.
|
||||||
|
//If no threads are waiting for the lock, then it should be null.
|
||||||
KThread OwnerThread = CurrThread.NextMutexThread;
|
KThread OwnerThread = CurrThread.NextMutexThread;
|
||||||
|
|
||||||
|
while (OwnerThread?.NextMutexThread != null && OwnerThread.MutexAddress != MutexAddress)
|
||||||
|
{
|
||||||
|
OwnerThread = OwnerThread.NextMutexThread;
|
||||||
|
}
|
||||||
|
|
||||||
CurrThread.NextMutexThread = null;
|
CurrThread.NextMutexThread = null;
|
||||||
|
|
||||||
if (OwnerThread != null)
|
if (OwnerThread != null)
|
||||||
|
@ -214,6 +223,7 @@ namespace Ryujinx.Core.OsHle.Kernel
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool CondVarWait(
|
private bool CondVarWait(
|
||||||
KThread WaitThread,
|
KThread WaitThread,
|
||||||
|
@ -246,6 +256,8 @@ namespace Ryujinx.Core.OsHle.Kernel
|
||||||
DoInsert &= CurrThread != WaitThread;
|
DoInsert &= CurrThread != WaitThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Only insert if the node doesn't already exist in the list.
|
||||||
|
//This prevents circular references.
|
||||||
if (DoInsert)
|
if (DoInsert)
|
||||||
{
|
{
|
||||||
if (WaitThread.NextCondVarThread != null)
|
if (WaitThread.NextCondVarThread != null)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue