summaryrefslogtreecommitdiffstats
path: root/generic/tclThreadTest.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2011-09-21 21:45:54 (GMT)
committerdgp <dgp@users.sourceforge.net>2011-09-21 21:45:54 (GMT)
commite82d81e2a36cc9b0e6a0d3024f072ff8c588cc7f (patch)
treef337fcc5d41e6fd203f45e59d6048799f80b8cac /generic/tclThreadTest.c
parent55d006f52db784e77fdc99b6bcaceeae689da92c (diff)
downloadtcl-e82d81e2a36cc9b0e6a0d3024f072ff8c588cc7f.zip
tcl-e82d81e2a36cc9b0e6a0d3024f072ff8c588cc7f.tar.gz
tcl-e82d81e2a36cc9b0e6a0d3024f072ff8c588cc7f.tar.bz2
Revise the thread exit handling of the [testthread] command so that it
properly maintains the per-process data structures even when the thread exits for reasons other than the [testthread exit] command.
Diffstat (limited to 'generic/tclThreadTest.c')
-rw-r--r--generic/tclThreadTest.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index 71d5a66..3345081 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -46,7 +46,7 @@ static Tcl_ThreadDataKey dataKey;
* protected by threadMutex.
*/
-static ThreadSpecificData *threadList;
+static ThreadSpecificData *threadList = NULL;
/*
* The following bit-values are legal for the "flags" field of the
@@ -623,9 +623,9 @@ NewTestThread(
* Clean up.
*/
- ListRemove(tsdPtr);
- Tcl_Release(tsdPtr->interp);
Tcl_DeleteInterp(tsdPtr->interp);
+ Tcl_Release(tsdPtr->interp);
+ ListRemove(tsdPtr);
Tcl_ExitThread(result);
TCL_THREAD_CREATE_RETURN;
@@ -744,6 +744,7 @@ ListRemove(
tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr;
}
tsdPtr->nextPtr = tsdPtr->prevPtr = 0;
+ tsdPtr->interp = NULL;
Tcl_MutexUnlock(&threadMutex);
}
@@ -1148,6 +1149,11 @@ ThreadExitProc(
char *threadEvalScript = clientData;
ThreadEventResult *resultPtr, *nextPtr;
Tcl_ThreadId self = Tcl_GetCurrentThread();
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+
+ if (tsdPtr->interp != NULL) {
+ ListRemove(tsdPtr);
+ }
Tcl_MutexLock(&threadMutex);