From ad2c386d6ad99d3021e33cbbfb311150b2586c93 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 10 Jan 2019 00:32:50 +0100 Subject: [PATCH] Move TLS key deletion to openblas_quit fixes #1954 (as suggested by thrasibule in that issue) --- driver/others/memory.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 6f7a7db82..72d3e173c 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -1073,11 +1073,6 @@ static volatile int memory_initialized = 0; } free(table); } -#if defined(OS_WINDOWS) - TlsFree(local_storage_key); -#else - pthread_key_delete(local_storage_key); -#endif } static void blas_memory_init(){ @@ -1491,6 +1486,14 @@ void DESTRUCTOR gotoblas_quit(void) { blas_shutdown(); +#if defined(SMP) +#if defined(OS_WINDOWS) + TlsFree(local_storage_key); +#else + pthread_key_delete(local_storage_key); +#endif +#endif + #ifdef PROFILE moncontrol (0); #endif