win32: Properly wait unil the thread finishes in dll unload
Without this we run into a problem. After 50ms we forcably kill the pool thread. However, if the pool thread currently holds the allocation lock, but doesn't get scheduled within 50ms, said lock will never be released causing an infinite deadlock and preventing the DLL from releasing. Further, in the unload scenario (as opposed to process exit), we may actually want to let the thread pool finish in case it's working on finishing an operation on another thread (since the user may be expecting the answer).
This commit is contained in:
parent
b16fa2e711
commit
b89aef2f32
|
@ -462,14 +462,7 @@ int BLASFUNC(blas_thread_shutdown)(void){
|
||||||
|
|
||||||
for(i = 0; i < blas_num_threads - 1; i++){
|
for(i = 0; i < blas_num_threads - 1; i++){
|
||||||
// Could also just use WaitForMultipleObjects
|
// Could also just use WaitForMultipleObjects
|
||||||
DWORD wait_thread_value = WaitForSingleObject(blas_threads[i], 50);
|
DWORD wait_thread_value = WaitForSingleObject(blas_threads[i], INFINITE);
|
||||||
|
|
||||||
#ifndef OS_WINDOWSSTORE
|
|
||||||
// TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
|
|
||||||
if (WAIT_OBJECT_0 != wait_thread_value) {
|
|
||||||
TerminateThread(blas_threads[i],0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CloseHandle(blas_threads[i]);
|
CloseHandle(blas_threads[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue