diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-07-23 16:53:42 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2015-07-23 16:53:42 (GMT) |
commit | 61947d12ec0d917d65a31b72dd14c2ee52c2ce5a (patch) | |
tree | 73d5cc27a2fdf277ab22129857f9bd85e2f6a300 /generic | |
parent | b6b49cf918923cfd65f36e367eb53becaaf6b264 (diff) | |
parent | bc9648f913a629f7845e64a802b2519bb5a729a7 (diff) | |
download | tcl-61947d12ec0d917d65a31b72dd14c2ee52c2ce5a.zip tcl-61947d12ec0d917d65a31b72dd14c2ee52c2ce5a.tar.gz tcl-61947d12ec0d917d65a31b72dd14c2ee52c2ce5a.tar.bz2 |
Fix bug [57945b574a6df0332efc4ac96b066f7c347b28f7|57945b574a]: lock in forking process under heavy multithreading. Thanks to Joe Mistachkin for the implementation of the fix, and Gustaf Neumann for the original report and testing the fix.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclInt.h | 3 | ||||
-rw-r--r-- | generic/tclThread.c | 37 |
2 files changed, 40 insertions, 0 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 18574c3..f39e77d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -2681,6 +2681,9 @@ MODULE_SCOPE void TclpInitUnlock(void); MODULE_SCOPE Tcl_Obj * TclpObjListVolumes(void); MODULE_SCOPE void TclpMasterLock(void); MODULE_SCOPE void TclpMasterUnlock(void); +MODULE_SCOPE void TclpMutexLock(void); +MODULE_SCOPE void TclpMutexUnlock(void); +MODULE_SCOPE void TclMutexUnlockAndFinalize(Tcl_Mutex *mutex); MODULE_SCOPE int TclpMatchFiles(Tcl_Interp *interp, char *separators, Tcl_DString *dirPtr, char *pattern, char *tail); MODULE_SCOPE int TclpObjNormalizePath(Tcl_Interp *interp, diff --git a/generic/tclThread.c b/generic/tclThread.c index d6b5bcb..087d735 100644 --- a/generic/tclThread.c +++ b/generic/tclThread.c @@ -283,6 +283,43 @@ Tcl_MutexFinalize( /* *---------------------------------------------------------------------- * + * TclMutexUnlockAndFinalize -- + * + * This procedure is invoked to unlock and then finalize a mutex. + * The mutex must have been locked by Tcl_MutexLock. It is also + * removed from the list of remembered objects. The mutex can no + * longer be used after calling this procedure. + * + * Results: + * None. + * + * Side effects: + * Remove the mutex from the list. + * + *---------------------------------------------------------------------- + */ + +void +TclMutexUnlockAndFinalize( + Tcl_Mutex *mutexPtr) +{ + Tcl_Mutex mutex; + TclpMasterLock(); + TclpMutexLock(); +#ifdef TCL_THREADS + mutex = *mutexPtr; + *mutexPtr = NULL; /* Force it to be created again. */ + Tcl_MutexUnlock(&mutex); + TclpFinalizeMutex(&mutex); +#endif + ForgetSyncObject(mutexPtr, &mutexRecord); + TclpMutexUnlock(); + TclpMasterUnlock(); +} + +/* + *---------------------------------------------------------------------- + * * TclRememberCondition * * Keep a list of condition variables used during finalization. |