summaryrefslogtreecommitdiffstats
path: root/generic/tclThread.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclThread.c')
-rw-r--r--generic/tclThread.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 64e956a..db326ad 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.c
@@ -305,12 +305,17 @@ void
Tcl_MutexUnlockAndFinalize(
Tcl_Mutex *mutexPtr)
{
+ Tcl_Mutex mutex;
TclpMasterLock();
+ TclpMutexLock();
#ifdef TCL_THREADS
- Tcl_MutexUnlock(mutexPtr);
- TclpFinalizeMutex(mutexPtr);
+ mutex = *mutexPtr;
+ *mutexPtr = NULL; /* Force it to be created again. */
+ Tcl_MutexUnlock(&mutex);
+ TclpFinalizeMutex(&mutex);
#endif
- ForgetSyncObject(mutexPtr, &mutexRecord);
+ ForgetSyncObject(&mutex, &mutexRecord);
+ TclpMutexUnlock();
TclpMasterUnlock();
}