mirror of
https://github.com/skyline-emu/skyline.git
synced 2025-01-10 20:19:24 +01:00
Fix WaitForAddress
timeout signal race
A race could occur from the timeout path in `WaitForAddress` taking place at the same time as `SignalToAddress` has been caused, this causes a deadlock due to double-insertion.
This commit is contained in:
parent
0f1d97fe2c
commit
e8a1bd1aad
@ -320,13 +320,18 @@ namespace skyline::kernel::type {
|
||||
std::scoped_lock lock{syncWaiterMutex};
|
||||
auto queue{syncWaiters.equal_range(address)};
|
||||
auto iterator{std::find(queue.first, queue.second, SyncWaiters::value_type{address, state.thread})};
|
||||
if (iterator != queue.second)
|
||||
if (iterator != queue.second) {
|
||||
if (syncWaiters.erase(iterator) == queue.second)
|
||||
// We need to update the boolean flag denoting that there are no more threads waiting on this address
|
||||
__atomic_store_n(address, false, __ATOMIC_SEQ_CST);
|
||||
} else {
|
||||
state.scheduler->WaitSchedule(false);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
state.scheduler->InsertThread(state.thread);
|
||||
state.scheduler->WaitSchedule();
|
||||
state.scheduler->WaitSchedule(false);
|
||||
|
||||
return result::TimedOut;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user