summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorvasiljevic <zv@archiware.com>2005-04-07 11:29:33 (GMT)
committervasiljevic <zv@archiware.com>2005-04-07 11:29:33 (GMT)
commit6ca86ff55e9908c05d9fff0366e849a58dfa4d2f (patch)
treebc23a6c4879c6ec2f3be0c65798ddec8ebe7c76b /win
parentb1b25f985a53897c4403e2236c236453ecf5e4b4 (diff)
downloadtcl-6ca86ff55e9908c05d9fff0366e849a58dfa4d2f.zip
tcl-6ca86ff55e9908c05d9fff0366e849a58dfa4d2f.tar.gz
tcl-6ca86ff55e9908c05d9fff0366e849a58dfa4d2f.tar.bz2
Renamed TclWinFreeAllocCache to TclpFreeAllocCache and fixed
to recognize when being called with NULL argument. This is a signal for it to clean up the tsd key associated with the threading allocator. Part of fixing the Tcl Bug #1178445.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinThrd.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index 05a321b..953a154 100644
--- a/win/tclWinThrd.c
+++ b/win/tclWinThrd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.9 2004/10/28 21:12:38 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.10 2005/04/07 11:29:33 vasiljevic Exp $
*/
#include "tclWinInt.h"
@@ -680,13 +680,16 @@ TclpFinalizeThreadData(keyPtr)
DWORD *indexPtr;
BOOL success;
-#if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG)
- TclWinFreeAllocCache();
-#endif
if (*keyPtr != NULL) {
indexPtr = *(DWORD **)keyPtr;
result = (VOID *)TlsGetValue(*indexPtr);
if (result != NULL) {
+#if defined(USE_THREAD_ALLOC) && !defined(TCL_MEM_DEBUG)
+ if (indexPtr == &key) {
+ TclpFreeAllocCache(result);
+ return;
+ }
+#endif
ckfree((char *)result);
success = TlsSetValue(*indexPtr, (void *)NULL);
if (!success) {
@@ -1078,7 +1081,7 @@ TclpGetAllocCache(void)
if (!once) {
/*
- * We need to make sure that TclWinFreeAllocCache is called
+ * We need to make sure that TclpFreeAllocCache is called
* on each thread that calls this, but only on threads that
* call this.
*/
@@ -1107,30 +1110,28 @@ TclpSetAllocCache(void *ptr)
}
void
-TclWinFreeAllocCache(void)
+TclpFreeAllocCache(void *ptr)
{
- void *ptr;
BOOL success;
- ptr = TlsGetValue(key);
if (ptr != NULL) {
- success = TlsSetValue(key, NULL);
+ /*
+ * Called by the pthread lib when a thread exits
+ */
+ TclFreeAllocCache(ptr);
+ success = TlsSetValue(key, NULL);
if (!success) {
- panic("TlsSetValue failed from TclWinFreeAllocCache!");
+ panic("TlsSetValue failed from TclpFreeAllocCache!");
}
- TclFreeAllocCache(ptr);
- } else {
- if (GetLastError() != NO_ERROR) {
- panic("TlsGetValue failed from TclWinFreeAllocCache!");
- }
- }
-
- if (once) {
+ } else if (once) {
+ /*
+ * Called by us in TclFinalizeThreadAlloc() during
+ * the library finalization initiated from Tcl_Finalize()
+ */
success = TlsFree(key);
if (!success) {
- Tcl_Panic("TlsFree failed from TclWinFreeAllocCache!");
+ Tcl_Panic("TlsFree failed from TclpFreeAllocCache!");
}
-
once = 0; /* reset for next time. */
}
}