diff options
| author | dgp@users.sourceforge.net <dgp> | 2011-09-21 21:45:54 (GMT) |
|---|---|---|
| committer | dgp@users.sourceforge.net <dgp> | 2011-09-21 21:45:54 (GMT) |
| commit | 5ed5a79f469f4407d452df4910c627751ac09f50 (patch) | |
| tree | f337fcc5d41e6fd203f45e59d6048799f80b8cac /generic/tclThreadTest.c | |
| parent | 2eb76970237068dfc76319617d80c27330c0b5eb (diff) | |
| download | tcl-5ed5a79f469f4407d452df4910c627751ac09f50.zip tcl-5ed5a79f469f4407d452df4910c627751ac09f50.tar.gz tcl-5ed5a79f469f4407d452df4910c627751ac09f50.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.c | 12 |
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); |
