summaryrefslogtreecommitdiffstats
path: root/generic/tclThread.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-23 17:09:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-07-23 17:09:58 (GMT)
commit7578a2c2bd45b8bcb5111af7bf3eff02ae8dfedc (patch)
tree085eb933a60ff0edec54f99a646543cbc8f64816 /generic/tclThread.c
parentfff74476830d03608f97f0003066b1a8dafe06ae (diff)
parent7d2d8c6e1118e4a9efca45f358528535202145fc (diff)
downloadtcl-7578a2c2bd45b8bcb5111af7bf3eff02ae8dfedc.zip
tcl-7578a2c2bd45b8bcb5111af7bf3eff02ae8dfedc.tar.gz
tcl-7578a2c2bd45b8bcb5111af7bf3eff02ae8dfedc.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/tclThread.c')
-rw-r--r--generic/tclThread.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 198fa6a..c2112b7 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -284,6 +284,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.