diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2003-09-29 21:38:47 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2003-09-29 21:38:47 (GMT) |
commit | 51d61f0f3368b5b9b14bbbbefb0a2aedb30ed5e3 (patch) | |
tree | 493b7c36e3c10db4c4a6edd067cf03ec4aa1a60a /generic/tclBasic.c | |
parent | ab6eb1243a00175b523c0b8ca52aa43f6edec906 (diff) | |
download | tcl-51d61f0f3368b5b9b14bbbbefb0a2aedb30ed5e3.zip tcl-51d61f0f3368b5b9b14bbbbefb0a2aedb30ed5e3.tar.gz tcl-51d61f0f3368b5b9b14bbbbefb0a2aedb30ed5e3.tar.bz2 |
TIP#121 (app exit proc API) implementation from Joe Mistachkin
Diffstat (limited to 'generic/tclBasic.c')
-rw-r--r-- | generic/tclBasic.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 8c1b739..71d0874 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.87 2003/09/29 14:37:14 dkf Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.88 2003/09/29 21:38:49 dkf Exp $ */ #include "tclInt.h" @@ -384,6 +384,19 @@ Tcl_CreateInterp() iPtr->execEnvPtr = TclCreateExecEnv(interp); /* + * Initialise the resource limiting framework. + */ + + iPtr->limitCheckCounter = 0; + iPtr->limits = 0; + iPtr->timeGranularity = 0; + iPtr->timeLimit = 0; + iPtr->timeLimitHandlers = NULL; + iPtr->cmdcountGranularity = 0; + iPtr->cmdcountLimit = 0; + iPtr->cmdcountLimitHandlers = NULL; + + /* * Initialize the compilation and execution statistics kept for this * interpreter. */ @@ -969,6 +982,7 @@ DeleteInterpProc(interp) Tcl_HashSearch search; Tcl_HashTable *hTablePtr; ResolverScheme *resPtr, *nextResPtr; + LimitHandler *lhPtr, *nextLhPtr; /* * Punt if there is an error in the Tcl_Release/Tcl_Preserve matchup. @@ -990,6 +1004,26 @@ DeleteInterpProc(interp) TclHandleFree(iPtr->handle); /* + * Destroy any resource limiting handlers that this interpreter + * has; we're on our way out now, so failing because of resource + * limits now would be very silly indeed. + */ + + iPtr->limits = 0; + for (lhPtr=iPtr->timeLimitHandlers ; lhPtr!=NULL ; lhPtr=nextLhPtr) { + nextLhPtr = lhPtr->next; + Tcl_DecrRefCount(lhPtr->handlerObj); + lhPtr->handlerObj = NULL; + Tcl_EventuallyFree((char *) lhPtr, TCL_DYNAMIC); + } + for (lhPtr=iPtr->cmdcountLimitHandlers ; lhPtr!=NULL ; lhPtr=nextLhPtr) { + nextLhPtr = lhPtr->next; + Tcl_DecrRefCount(lhPtr->handlerObj); + lhPtr->handlerObj = NULL; + Tcl_EventuallyFree((char *) lhPtr, TCL_DYNAMIC); + } + + /* * Dismantle everything in the global namespace except for the * "errorInfo" and "errorCode" variables. These remain until the * namespace is actually destroyed, in case any errors occur. |