Tcl Source Code

Artifact [c37b120f2c]
Login

Artifact c37b120f2c23a4e5f9d1f6c45b61aaf016583ca3:

Attachment "pthread-callback.patch" to ticket [3cc1d91345] added by gustafn2 2016-09-26 18:23:51. (unpublished)
Index: unix/tclUnixThrd.c
==================================================================
--- unix/tclUnixThrd.c
+++ unix/tclUnixThrd.c
@@ -720,19 +720,20 @@
 TclpFreeAllocCache(
     void *ptr)
 {
     if (ptr != NULL) {
 	/*
-	 * Called by the pthread lib when a thread exits
+	 * Called by TclFinalizeThreadAllocThread() during the thread
+	 * finalization initiated from Tcl_FinalizeThread()
 	 */
 
 	TclFreeAllocCache(ptr);
 	pthread_setspecific(key, NULL);
 
     } else if (initialized) {
 	/*
-	 * Called by us in TclFinalizeThreadAlloc() during the library
+	 * Called by TclFinalizeThreadAlloc() during the process
 	 * finalization initiated from Tcl_Finalize()
 	 */
 
 	pthread_key_delete(key);
 	initialized = 0;
@@ -743,11 +744,11 @@
 TclpGetAllocCache(void)
 {
     if (!initialized) {
 	pthread_mutex_lock(allocLockPtr);
 	if (!initialized) {
-	    pthread_key_create(&key, TclpFreeAllocCache);
+	    pthread_key_create(&key, NULL);
 	    initialized = 1;
 	}
 	pthread_mutex_unlock(allocLockPtr);
     }
     return pthread_getspecific(key);