multithreading: close windows thread handle before releasing exit_barrier in thread_cleanup

Fixes out of memory errors when creating lots of threads on windows,
joining them and then again creating many threads (see e.g. the
atomic-incf/decf tests).
This commit is contained in:
Marius Gerbershagen 2019-08-25 20:54:47 +02:00
parent 0080acd4ce
commit 574a90a7c3

View file

@ -206,12 +206,12 @@ thread_cleanup(void *aux)
#endif
process->process.env = NULL;
ecl_unlist_process(process);
mp_barrier_unblock(3, process->process.exit_barrier, @':disable', ECL_T);
ecl_set_process_env(NULL);
if (env) _ecl_dealloc_env(env);
#ifdef ECL_WINDOWS_THREADS
CloseHandle(process->process.thread);
#endif
mp_barrier_unblock(3, process->process.exit_barrier, @':disable', ECL_T);
ecl_set_process_env(NULL);
if (env) _ecl_dealloc_env(env);
AO_store_release((AO_t*)&process->process.phase, ECL_PROCESS_INACTIVE);
}