diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-04-01 12:00:36 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-04-01 12:00:36 (GMT) |
commit | eba6ef86a9f558df5aefa64822b05a678517740d (patch) | |
tree | bb5296be8b28a43682af2305936d3c551424d64d /unix/tclUnixThrd.c | |
parent | 890c05b7130f318175535dc345dc530c9c52dd48 (diff) | |
parent | ffcf42745c6b45037104720cdd15d5d7003fdb63 (diff) | |
download | tcl-eba6ef86a9f558df5aefa64822b05a678517740d.zip tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.gz tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.bz2 |
merge trunk
Diffstat (limited to 'unix/tclUnixThrd.c')
-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 ca3db3e..76b6b80 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -623,7 +623,6 @@ TclpFinalizeCondition( */ #ifdef USE_THREAD_ALLOC -static volatile int initialized = 0; static pthread_key_t key; typedef struct { @@ -660,6 +659,14 @@ TclpFreeAllocMutex( } void +TclpInitAllocCache(void) +{ + pthread_mutex_lock(allocLockPtr); + pthread_key_create(&key, TclpFreeAllocCache); + pthread_mutex_unlock(allocLockPtr); +} + +void TclpFreeAllocCache( void *ptr) { @@ -670,29 +677,15 @@ 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 * 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); } |