diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | generic/tclEvent.c | 4 | ||||
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclThread.c | 8 | ||||
-rw-r--r-- | unix/tclUnixThrd.c | 30 | ||||
-rw-r--r-- | win/tclWinThrd.c | 41 |
6 files changed, 86 insertions, 12 deletions
@@ -5,6 +5,18 @@ another thread was ineffective if the original's stringrep had been invalidated as what happens when it gets muted to a list. + * win/tclWinTime.c: If the Tcl_ExitProc (StopCalibration) is + called from the stack frame of DllMain's PROCESS_DETACH, the + wait operation should timeout and continue. + + * generic/tclInt.h: + * generic/tclThread.c: + * generic/tclEvent.c: + * unix/tclUnixThrd.c: + * win/tclWinThrd.c: Provisions made so masterLock, initLock, + allocLock and joinLock mutexes can be recovered during + Tcl_Finalize. + 2004-04-22 Donal K. Fellows <donal.k.fellows@man.ac.uk> * doc/switch.n: Reworked the examples to be more systematically diff --git a/generic/tclEvent.c b/generic/tclEvent.c index 32ec7f8..3c067a4 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEvent.c,v 1.33 2004/04/23 02:04:54 davygrvy Exp $ + * RCS: @(#) $Id: tclEvent.c,v 1.34 2004/04/23 07:21:15 davygrvy Exp $ */ #include "tclInt.h" @@ -952,7 +952,7 @@ Tcl_Finalize() TclFinalizeMemorySubsystem(); inFinalize = 0; } - TclpInitUnlock(); + TclFinalizeLock(); } /* diff --git a/generic/tclInt.h b/generic/tclInt.h index f4d1359..c136248 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.152 2004/04/07 22:04:29 hobbs Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.153 2004/04/23 07:21:18 davygrvy Exp $ */ #ifndef _TCLINT @@ -1658,6 +1658,7 @@ EXTERN void TclFinalizeMemorySubsystem _ANSI_ARGS_((void)); EXTERN void TclFinalizeNotifier _ANSI_ARGS_((void)); EXTERN void TclFinalizeAsync _ANSI_ARGS_((void)); EXTERN void TclFinalizeSynchronization _ANSI_ARGS_((void)); +EXTERN void TclFinalizeLock _ANSI_ARGS_((void)); EXTERN void TclFinalizeThreadData _ANSI_ARGS_((void)); EXTERN int TclGlob _ANSI_ARGS_((Tcl_Interp *interp, char *pattern, Tcl_Obj *unquotedPrefix, diff --git a/generic/tclThread.c b/generic/tclThread.c index 5ddbb91..4a2d4b8 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.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: tclThread.c,v 1.6 2002/12/10 00:34:15 hobbs Exp $ + * RCS: @(#) $Id: tclThread.c,v 1.7 2004/04/23 07:21:36 davygrvy Exp $ */ #include "tclInt.h" @@ -30,9 +30,9 @@ typedef struct { char **list; /* List of pointers */ } SyncObjRecord; -static SyncObjRecord keyRecord; -static SyncObjRecord mutexRecord; -static SyncObjRecord condRecord; +static SyncObjRecord keyRecord = {0, 0, NULL}; +static SyncObjRecord mutexRecord = {0, 0, NULL}; +static SyncObjRecord condRecord = {0, 0, NULL}; /* * Prototypes of functions used only in this file diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c index f67248c..c087423 100644 --- a/unix/tclUnixThrd.c +++ b/unix/tclUnixThrd.c @@ -254,7 +254,37 @@ TclpInitLock() pthread_mutex_lock(&initLock); #endif } + +/* + *---------------------------------------------------------------------- + * + * TclpFinalizeLock + * + * This procedure is used to destroy all private resources used in + * this file. + * + * Results: + * None. + * + * Side effects: + * Destroys everything private. TclpInitLock must be held + * entering this function. + * + *---------------------------------------------------------------------- + */ +void +TclFinalizeLock () +{ +#ifdef TCL_THREADS + /* + * You do not need to destroy mutexes that were created with the + * PTHREAD_MUTEX_INITIALIZER macro. These mutexes do not need + * any destruction: masterLock, allocLock, and initLock. + */ + pthread_mutex_unlock(&initLock); +#endif +} /* *---------------------------------------------------------------------- diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index fd6ad65..80ef5ed 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.28 2004/01/11 20:36:48 davygrvy Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.29 2004/04/23 07:21:41 davygrvy Exp $ */ #include "tclWinInt.h" @@ -25,6 +25,7 @@ static CRITICAL_SECTION masterLock; static int init = 0; +static int allocOnce = 0; #define MASTER_LOCK EnterCriticalSection(&masterLock) #define MASTER_UNLOCK LeaveCriticalSection(&masterLock) @@ -393,18 +394,48 @@ Tcl_Mutex * Tcl_GetAllocMutex() { #ifdef TCL_THREADS - static int once = 0; - - if (!once) { + if (!allocOnce) { InitializeCriticalSection(&allocLock); - once = 1; + allocOnce = 1; } return &allocLockPtr; #else return NULL; #endif } + +/* + *---------------------------------------------------------------------- + * + * TclpFinalizeLock + * + * This procedure is used to destroy all private resources used in + * this file. + * + * Results: + * None. + * + * Side effects: + * Destroys everything private. TclpInitLock must be held + * entering this function. + * + *---------------------------------------------------------------------- + */ +void +TclFinalizeLock () +{ + MASTER_LOCK; + DeleteCriticalSection(&joinLock); + DeleteCriticalSection(&masterLock); + init = 0; +#ifdef TCL_THREADS + DeleteCriticalSection(&allocLock); +#endif + allocOnce = 0; + /* Destroy the critical section that we are holding. */ + DeleteCriticalSection(&initLock); +} #ifdef TCL_THREADS |