diff options
-rw-r--r-- | thread.h | 8 | ||||
-rw-r--r-- | win32/perllib.c | 4 | ||||
-rw-r--r-- | win32/win32thread.h | 5 |
3 files changed, 17 insertions, 0 deletions
@@ -117,6 +117,7 @@ #define INIT_THREADS cthread_init() #define YIELD cthread_yield() #define ALLOC_THREAD_KEY NOOP +#define FREE_THREAD_KEY NOOP #define SET_THREAD_SELF(thr) (thr->self = cthread_self()) #endif /* I_MACH_CTHREADS */ @@ -257,6 +258,13 @@ } STMT_END #endif +#ifndef FREE_THREAD_KEY +# define FREE_THREAD_KEY \ + STMT_START { \ + pthread_key_delete(PL_thr_key); \ + } STMT_END +#endif + #ifndef THREAD_RET_TYPE # define THREAD_RET_TYPE void * # define THREAD_RET_CAST(p) ((void *)(p)) diff --git a/win32/perllib.c b/win32/perllib.c index fae334608f..e2b245d84f 100644 --- a/win32/perllib.c +++ b/win32/perllib.c @@ -372,6 +372,10 @@ DllMain(HANDLE hModule, /* DLL module handle */ */ case DLL_PROCESS_DETACH: EndSockets(); +#if defined(USE_THREADS) || defined(USE_ITHREADS) + if (PL_curinterp) + FREE_THREAD_KEY; +#endif break; /* The attached process creates a new thread. */ diff --git a/win32/win32thread.h b/win32/win32thread.h index 809e0f7212..a52118b48e 100644 --- a/win32/win32thread.h +++ b/win32/win32thread.h @@ -175,6 +175,11 @@ END_EXTERN_C } \ } STMT_END +#define FREE_THREAD_KEY \ + STMT_START { \ + TlsFree(PL_thr_key); \ + } STMT_END + #if defined(USE_RTL_THREAD_API) && !defined(_MSC_VER) #define JOIN(t, avp) \ STMT_START { \ |