diff options
author | dgp <dgp@users.sourceforge.net> | 2018-06-26 17:00:29 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2018-06-26 17:00:29 (GMT) |
commit | 9da2aebeaebd1ccbfa806b0c3550774abc7ad778 (patch) | |
tree | 9dc2e6f4d73f15267c13a65293fa65fdf60f8c11 | |
parent | ed5ed756bc5993edb110e13b90028646b413e92d (diff) | |
download | tcl-9da2aebeaebd1ccbfa806b0c3550774abc7ad778.zip tcl-9da2aebeaebd1ccbfa806b0c3550774abc7ad778.tar.gz tcl-9da2aebeaebd1ccbfa806b0c3550774abc7ad778.tar.bz2 |
Use a thread exit handler, and not a custom exit proc for package cleanup.
-rw-r--r-- | generic/tclInt.h | 1 | ||||
-rw-r--r-- | generic/tclTest.c | 16 | ||||
-rw-r--r-- | generic/tclThreadTest.c | 17 |
3 files changed, 8 insertions, 26 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 64004d8..0a3285f 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -4532,7 +4532,6 @@ MODULE_SCOPE Tcl_PackageInitProc TclObjTest_Init; MODULE_SCOPE Tcl_PackageInitProc TclThread_Init; MODULE_SCOPE Tcl_PackageInitProc Procbodytest_Init; MODULE_SCOPE Tcl_PackageInitProc Procbodytest_SafeInit; -MODULE_SCOPE void TclThreadTestFinalize(); /* *---------------------------------------------------------------- diff --git a/generic/tclTest.c b/generic/tclTest.c index 952f384..45cca5a 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -52,7 +52,6 @@ #define TCL_STORAGE_CLASS DLLEXPORT EXTERN int Tcltest_Init(Tcl_Interp *interp); EXTERN int Tcltest_SafeInit(Tcl_Interp *interp); -EXTERN TCL_NORETURN void Tcltest_Exit(ClientData clientData); /* * Dynamic string shared by TestdcallCmd and DelCallbackProc; used to collect @@ -564,10 +563,6 @@ Tcltest_Init( return TCL_ERROR; } - - /* Finalizer */ - Tcl_SetExitProc(Tcltest_Exit); - /* * Create additional commands and math functions for testing Tcl. */ @@ -795,17 +790,6 @@ Tcltest_SafeInit( return Procbodytest_SafeInit(interp); } -TCL_NORETURN void Tcltest_Exit( - ClientData clientData -) { - int status = PTR2INT(clientData); - Tcl_Finalize(); - TclThreadTestFinalize(); - TclpExit(status); - Tcl_Panic("OS exit failed!"); -} - - /* *---------------------------------------------------------------------- * diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c index 92cfa13..35b3fc3 100644 --- a/generic/tclThreadTest.c +++ b/generic/tclThreadTest.c @@ -174,15 +174,6 @@ TclThread_Init( Tcl_CreateObjCommand(interp, "testthread", ThreadObjCmd, NULL, NULL); return TCL_OK; } - - -void TclThreadTestFinalize() { - if (errorProcString != NULL) { - ckfree(errorProcString); - errorProcString= NULL; - } - return; -} /* *---------------------------------------------------------------------- @@ -1166,6 +1157,14 @@ ThreadExitProc( Tcl_MutexLock(&threadMutex); + if (self == errorThreadId) { + if (errorProcString) { /* Extra safety */ + ckfree(errorProcString); + errorProcString = NULL; + } + errorThreadId = 0; + } + if (threadEvalScript) { ckfree(threadEvalScript); threadEvalScript = NULL; |