mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 08:55:48 +00:00
Create new threads suspended on Windows and WP to prevent a race condition
This commit is contained in:
parent
cdf07e6905
commit
929487249d
@ -157,7 +157,7 @@ int PltCreateThread(ThreadEntry entry, void* context, PLT_THREAD *thread) {
|
||||
return -1;
|
||||
}
|
||||
thread->cancelled = 0;
|
||||
thread->handle = CreateThread(NULL, 0, ThreadProc, ctx, 0, &thread->tid);
|
||||
thread->handle = CreateThread(NULL, 0, ThreadProc, ctx, CREATE_SUSPENDED, &thread->tid);
|
||||
if (thread->handle == NULL) {
|
||||
CloseHandle(thread->termevent);
|
||||
free(ctx);
|
||||
@ -170,6 +170,9 @@ int PltCreateThread(ThreadEntry entry, void* context, PLT_THREAD *thread) {
|
||||
thread_head = thread;
|
||||
PltUnlockMutex(&thread_list_lock);
|
||||
|
||||
// Now the thread can run
|
||||
ResumeThread(thread->handle);
|
||||
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,12 @@ CreateThread(
|
||||
_In_ DWORD dwCreationFlags,
|
||||
_Out_opt_ LPDWORD lpThreadId
|
||||
);
|
||||
|
||||
DWORD
|
||||
WINAPI
|
||||
ResumeThread(
|
||||
_In_ HANDLE hThread
|
||||
);
|
||||
#endif
|
||||
|
||||
int initializePlatformThreads(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user