mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 17:19:18 +01:00
coreinit: Fix race condition that causes crash (#1138)
This commit is contained in:
parent
fa4ad9b8c1
commit
111e383d1b
@ -1159,9 +1159,11 @@ namespace coreinit
|
|||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
std::vector<pid_t> g_schedulerThreadIds;
|
std::vector<pid_t> g_schedulerThreadIds;
|
||||||
|
std::mutex g_schedulerThreadIdsLock;
|
||||||
|
|
||||||
std::vector<pid_t>& OSGetSchedulerThreadIds()
|
std::vector<pid_t>& OSGetSchedulerThreadIds()
|
||||||
{
|
{
|
||||||
|
std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock);
|
||||||
return g_schedulerThreadIds;
|
return g_schedulerThreadIds;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1183,7 +1185,10 @@ namespace coreinit
|
|||||||
}
|
}
|
||||||
|
|
||||||
pid_t tid = gettid();
|
pid_t tid = gettid();
|
||||||
g_schedulerThreadIds.emplace_back(tid);
|
{
|
||||||
|
std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock);
|
||||||
|
g_schedulerThreadIds.emplace_back(tid);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
t_schedulerFiber = Fiber::PrepareCurrentThread();
|
t_schedulerFiber = Fiber::PrepareCurrentThread();
|
||||||
@ -1238,7 +1243,10 @@ namespace coreinit
|
|||||||
sSchedulerThreads.clear();
|
sSchedulerThreads.clear();
|
||||||
g_schedulerThreadHandles.clear();
|
g_schedulerThreadHandles.clear();
|
||||||
#if BOOST_OS_LINUX
|
#if BOOST_OS_LINUX
|
||||||
g_schedulerThreadIds.clear();
|
{
|
||||||
|
std::lock_guard schedulerThreadIdsLockGuard(g_schedulerThreadIdsLock);
|
||||||
|
g_schedulerThreadIds.clear();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
// clean up all fibers
|
// clean up all fibers
|
||||||
for (auto& it : g_idleLoopFiber)
|
for (auto& it : g_idleLoopFiber)
|
||||||
|
Loading…
Reference in New Issue
Block a user