Fix for #2063tags/v0.3.6^2
| @@ -461,13 +461,18 @@ int BLASFUNC(blas_thread_shutdown)(void){ | |||||
| SetEvent(pool.killed); | SetEvent(pool.killed); | ||||
| for(i = 0; i < blas_num_threads - 1; i++){ | for(i = 0; i < blas_num_threads - 1; i++){ | ||||
| // Could also just use WaitForMultipleObjects | |||||
| WaitForSingleObject(blas_threads[i], 5); //INFINITE); | WaitForSingleObject(blas_threads[i], 5); //INFINITE); | ||||
| #ifndef OS_WINDOWSSTORE | #ifndef OS_WINDOWSSTORE | ||||
| // TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP | // TerminateThread is only available with WINAPI_DESKTOP and WINAPI_SYSTEM not WINAPI_APP in UWP | ||||
| TerminateThread(blas_threads[i],0); | TerminateThread(blas_threads[i],0); | ||||
| #endif | #endif | ||||
| CloseHandle(blas_threads[i]); | |||||
| } | } | ||||
| CloseHandle(pool.filled); | |||||
| CloseHandle(pool.killed); | |||||
| blas_server_avail = 0; | blas_server_avail = 0; | ||||
| } | } | ||||
| @@ -1313,6 +1313,13 @@ void blas_memory_free_nolock(void * map_address) { | |||||
| free(map_address); | free(map_address); | ||||
| } | } | ||||
| #ifdef SMP | |||||
| void blas_thread_memory_cleanup(void) { | |||||
| blas_memory_cleanup((void*)get_memory_table()); | |||||
| } | |||||
| #endif | |||||
| void blas_shutdown(void){ | void blas_shutdown(void){ | ||||
| #ifdef SMP | #ifdef SMP | ||||
| BLASFUNC(blas_thread_shutdown)(); | BLASFUNC(blas_thread_shutdown)(); | ||||
| @@ -1322,7 +1329,7 @@ void blas_shutdown(void){ | |||||
| /* Only cleanupIf we were built for threading and TLS was initialized */ | /* Only cleanupIf we were built for threading and TLS was initialized */ | ||||
| if (local_storage_key) | if (local_storage_key) | ||||
| #endif | #endif | ||||
| blas_memory_cleanup((void*)get_memory_table()); | |||||
| blas_thread_memory_cleanup(); | |||||
| #ifdef SEEK_ADDRESS | #ifdef SEEK_ADDRESS | ||||
| base_address = 0UL; | base_address = 0UL; | ||||
| @@ -1552,7 +1559,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser | |||||
| break; | break; | ||||
| case DLL_THREAD_DETACH: | case DLL_THREAD_DETACH: | ||||
| #if defined(SMP) | #if defined(SMP) | ||||
| blas_memory_cleanup((void*)get_memory_table()); | |||||
| blas_thread_memory_cleanup(); | |||||
| #endif | #endif | ||||
| break; | break; | ||||
| case DLL_PROCESS_DETACH: | case DLL_PROCESS_DETACH: | ||||
| @@ -40,15 +40,25 @@ | |||||
| void gotoblas_init(void); | void gotoblas_init(void); | ||||
| void gotoblas_quit(void); | void gotoblas_quit(void); | ||||
| #if defined(SMP) && defined(USE_TLS) | |||||
| void blas_thread_memory_cleanup(void); | |||||
| #endif | |||||
| BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) { | BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) { | ||||
| if (reason == DLL_PROCESS_ATTACH) { | |||||
| gotoblas_init(); | |||||
| } | |||||
| if (reason == DLL_PROCESS_DETACH) { | |||||
| gotoblas_quit(); | |||||
| switch(reason) { | |||||
| case DLL_PROCESS_ATTACH: | |||||
| gotoblas_init(); | |||||
| break; | |||||
| case DLL_PROCESS_DETACH: | |||||
| gotoblas_quit(); | |||||
| break; | |||||
| case DLL_THREAD_ATTACH: | |||||
| break; | |||||
| case DLL_THREAD_DETACH: | |||||
| #if defined(SMP) && defined(USE_TLS) | |||||
| blas_thread_memory_cleanup(); | |||||
| #endif | |||||
| break; | |||||
| } | } | ||||
| return TRUE; | return TRUE; | ||||