Skip to content

Commit

Permalink
Also call CloseHandle on each thread, as well as on the event so as t…
Browse files Browse the repository at this point in the history
…o not leak thread handles.
  • Loading branch information
embray committed Mar 19, 2019
1 parent 4ad694e commit 8ba9e2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions driver/others/blas_server_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,18 @@ int BLASFUNC(blas_thread_shutdown)(void){
SetEvent(pool.killed);

for(i = 0; i < blas_num_threads - 1; i++){
// Could also just use WaitForMultipleObjects
WaitForSingleObject(blas_threads[i], 5); //INFINITE);
#ifndef OS_WINDOWSSTORE
// TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP
TerminateThread(blas_threads[i],0);
#endif
CloseHandle(blas_threads[i]);
}

CloseHandle(pool.filled);
CloseHandle(pool.killed);

blas_server_avail = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion exports/dllinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
break;
case DLL_THREAD_DETACH:
#if defined(SMP) && defined(USE_TLS)
blas_thread_memory_cleanup(void);
blas_thread_memory_cleanup();
#endif
break;
}
Expand Down

0 comments on commit 8ba9e2a

Please sign in to comment.