summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-05-10 16:03:13 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-05-10 16:03:13 (GMT)
commit08df07894566ad1a3cf2dc750ab9322761ee400f (patch)
tree620e18d988e661349d957eb09da1777d21f4b2f9 /unix/tclUnixThrd.c
parent20baf86d1e03655bb6d7fae562091e95fe52db15 (diff)
parent313d238fb894ff0775f40ec5aee77627742a3b1b (diff)
downloadtcl-dgp_dup_encoding_fix.zip
tcl-dgp_dup_encoding_fix.tar.gz
tcl-dgp_dup_encoding_fix.tar.bz2
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 554a2dc..cf81850 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 {
@@ -710,6 +709,14 @@ TclpFreeAllocMutex(
}
void
+TclpInitAllocCache(void)
+{
+ pthread_mutex_lock(allocLockPtr);
+ pthread_key_create(&key, TclpFreeAllocCache);
+ pthread_mutex_unlock(allocLockPtr);
+}
+
+void
TclpFreeAllocCache(
void *ptr)
{
@@ -721,28 +728,14 @@ 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);
}