diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/tclUnixThrd.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index 554a2dc..070a107 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -673,7 +673,6 @@ TclpInetNtoa( */ #ifdef USE_THREAD_ALLOC -static volatile int initialized = 0; static pthread_key_t key; typedef struct allocMutex { @@ -720,29 +719,23 @@ TclpFreeAllocCache( TclFreeAllocCache(ptr); pthread_setspecific(key, NULL); - - } else if (initialized) { - /* - * Called by us in TclFinalizeThreadAlloc() during the library - * finalization initiated from Tcl_Finalize() - */ - + + } else { pthread_key_delete(key); - initialized = 0; } } +void +TclpInitThreadAlloc(void) +{ + pthread_mutex_lock(allocLockPtr); + pthread_key_create(&key, TclpFreeAllocCache); + pthread_mutex_unlock(allocLockPtr); +} + void * TclpGetAllocCache(void) { - if (!initialized) { - pthread_mutex_lock(allocLockPtr); - if (!initialized) { - pthread_key_create(&key, TclpFreeAllocCache); - initialized = 1; - } - pthread_mutex_unlock(allocLockPtr); - } return pthread_getspecific(key); } |