mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-18 09:25:49 +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;
|
return -1;
|
||||||
}
|
}
|
||||||
thread->cancelled = 0;
|
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) {
|
if (thread->handle == NULL) {
|
||||||
CloseHandle(thread->termevent);
|
CloseHandle(thread->termevent);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
@ -170,6 +170,9 @@ int PltCreateThread(ThreadEntry entry, void* context, PLT_THREAD *thread) {
|
|||||||
thread_head = thread;
|
thread_head = thread;
|
||||||
PltUnlockMutex(&thread_list_lock);
|
PltUnlockMutex(&thread_list_lock);
|
||||||
|
|
||||||
|
// Now the thread can run
|
||||||
|
ResumeThread(thread->handle);
|
||||||
|
|
||||||
err = 0;
|
err = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,12 @@ CreateThread(
|
|||||||
_In_ DWORD dwCreationFlags,
|
_In_ DWORD dwCreationFlags,
|
||||||
_Out_opt_ LPDWORD lpThreadId
|
_Out_opt_ LPDWORD lpThreadId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
DWORD
|
||||||
|
WINAPI
|
||||||
|
ResumeThread(
|
||||||
|
_In_ HANDLE hThread
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int initializePlatformThreads(void);
|
int initializePlatformThreads(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user