summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-01 12:00:36 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-04-01 12:00:36 (GMT)
commiteba6ef86a9f558df5aefa64822b05a678517740d (patch)
treebb5296be8b28a43682af2305936d3c551424d64d /unix/tclUnixThrd.c
parent890c05b7130f318175535dc345dc530c9c52dd48 (diff)
parentffcf42745c6b45037104720cdd15d5d7003fdb63 (diff)
downloadtcl-eba6ef86a9f558df5aefa64822b05a678517740d.zip
tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.gz
tcl-eba6ef86a9f558df5aefa64822b05a678517740d.tar.bz2
merge trunk
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c27
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);
}