Fixed windows runner exiting before the death of all wait threads
This commit is contained in:
parent
1d2a5c2376
commit
f4cccfec3f
1 changed files with 19 additions and 0 deletions
|
@ -111,6 +111,10 @@ struct full_context {
|
||||||
static TCHAR g_mapping_name[] = TEXT("WinCriterionWorker_%lu");
|
static TCHAR g_mapping_name[] = TEXT("WinCriterionWorker_%lu");
|
||||||
|
|
||||||
static struct full_context local_ctx;
|
static struct full_context local_ctx;
|
||||||
|
|
||||||
|
static CRITICAL_SECTION wait_sync;
|
||||||
|
static CONDITION_VARIABLE wait_cond;
|
||||||
|
static LONG volatile wait_threads;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__unix__) || defined(__APPLE__)
|
#if defined(__unix__) || defined(__APPLE__)
|
||||||
|
@ -170,6 +174,10 @@ void init_proc_compat(void) {
|
||||||
perror(0);
|
perror(0);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
InitializeConditionVariable(&wait_cond);
|
||||||
|
InitializeCriticalSection(&wait_sync);
|
||||||
|
wait_threads = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +185,13 @@ void free_proc_compat(void) {
|
||||||
#ifndef VANILLA_WIN32
|
#ifndef VANILLA_WIN32
|
||||||
child_pump_running = false;
|
child_pump_running = false;
|
||||||
pthread_join(child_pump, NULL);
|
pthread_join(child_pump, NULL);
|
||||||
|
#else
|
||||||
|
EnterCriticalSection(&wait_sync);
|
||||||
|
while (wait_threads > 0)
|
||||||
|
SleepConditionVariableCS(&wait_cond, &wait_sync, INFINITE);
|
||||||
|
LeaveCriticalSection(&wait_sync);
|
||||||
|
|
||||||
|
DeleteCriticalSection(&wait_sync);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,6 +228,9 @@ static void CALLBACK handle_child_terminated(PVOID lpParameter,
|
||||||
msg.id.pid = pid;
|
msg.id.pid = pid;
|
||||||
cr_send_to_runner(&msg);
|
cr_send_to_runner(&msg);
|
||||||
|
|
||||||
|
if (InterlockedDecrement(&wait_threads) == 0)
|
||||||
|
WakeConditionVariable(&wait_cond);
|
||||||
|
|
||||||
HANDLE whandle = wctx->wait_handle;
|
HANDLE whandle = wctx->wait_handle;
|
||||||
free(lpParameter);
|
free(lpParameter);
|
||||||
UnregisterWaitEx(whandle, NULL);
|
UnregisterWaitEx(whandle, NULL);
|
||||||
|
@ -386,6 +404,7 @@ s_proc_handle *fork_process() {
|
||||||
.proc_handle = info.hProcess,
|
.proc_handle = info.hProcess,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
InterlockedIncrement (&wait_threads);
|
||||||
RegisterWaitForSingleObject(
|
RegisterWaitForSingleObject(
|
||||||
&wctx->wait_handle,
|
&wctx->wait_handle,
|
||||||
info.hProcess,
|
info.hProcess,
|
||||||
|
|
Loading…
Add table
Reference in a new issue