mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 14:31:17 +12:00
Fix memory leak by modifying MMURange in place. Aquire lock for __OSCreateHostThread.
This commit is contained in:
parent
0f9d27ae12
commit
aa472e13c5
6 changed files with 23 additions and 80 deletions
|
@ -208,53 +208,24 @@ namespace coreinit
|
|||
OSSuspendThread(ptr);
|
||||
}
|
||||
}
|
||||
if (__currentCoreThread[0])
|
||||
OSSuspendThread(__currentCoreThread[0]);
|
||||
if (__currentCoreThread[1])
|
||||
OSSuspendThread(__currentCoreThread[1]);
|
||||
if (__currentCoreThread[2])
|
||||
OSSuspendThread(__currentCoreThread[2]);
|
||||
|
||||
}
|
||||
|
||||
void ResumeAllThreads(bool* runningThreads)
|
||||
void ResumeAllThreads()
|
||||
{
|
||||
for (auto& thr : activeThread)
|
||||
{
|
||||
int i = 0;
|
||||
auto* ptr = (OSThread_t*)memory_getPointerFromVirtualOffset(thr);
|
||||
if (thr != 0)
|
||||
{
|
||||
if (runningThreads && runningThreads[i])
|
||||
if (s_threadToFiber.find(ptr) == s_threadToFiber.end())
|
||||
{
|
||||
if (s_threadToFiber.find(ptr) == s_threadToFiber.end())
|
||||
__OSCreateHostThread(ptr);
|
||||
OSResumeThread(ptr);
|
||||
}
|
||||
else if (!runningThreads)
|
||||
{
|
||||
if (s_threadToFiber.find(ptr) == s_threadToFiber.end())
|
||||
__OSCreateHostThread(ptr);
|
||||
OSResumeThread(ptr);
|
||||
__OSLockScheduler();
|
||||
__OSCreateHostThread(ptr);
|
||||
__OSUnlockScheduler();
|
||||
}
|
||||
OSResumeThread(ptr);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (__currentCoreThread[0])
|
||||
OSResumeThread(__currentCoreThread[0]);
|
||||
if (__currentCoreThread[1])
|
||||
OSResumeThread(__currentCoreThread[1]);
|
||||
if (__currentCoreThread[2])
|
||||
OSResumeThread(__currentCoreThread[2]);
|
||||
}
|
||||
|
||||
std::vector<OSThread_t*> GetAllThreads()
|
||||
{
|
||||
auto ret = std::vector<OSThread_t*>();
|
||||
ret.push_back(__currentCoreThread[0]);
|
||||
ret.push_back(__currentCoreThread[1]);
|
||||
ret.push_back(__currentCoreThread[2]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
MPTR funcPtr_threadEntry = 0;
|
||||
|
|
|
@ -525,8 +525,7 @@ namespace coreinit
|
|||
sint32 __OSResumeThreadInternal(OSThread_t* thread, sint32 resumeCount);
|
||||
sint32 OSResumeThread(OSThread_t* thread);
|
||||
void SuspendAllThreads();
|
||||
void ResumeAllThreads(bool* runningThreads);
|
||||
std::vector<OSThread_t*> GetAllThreads();
|
||||
void ResumeAllThreads();
|
||||
void OSContinueThread(OSThread_t* thread);
|
||||
void __OSSuspendThreadInternal(OSThread_t* thread);
|
||||
void __OSSuspendThreadNolock(OSThread_t* thread);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue