diff options
| author | Joe Mistachkin <joe@mistachkin.com> | 2015-05-17 18:03:15 (GMT) |
|---|---|---|
| committer | Joe Mistachkin <joe@mistachkin.com> | 2015-05-17 18:03:15 (GMT) |
| commit | fc49271c0a03ec5ed04419f535526f3d229929c4 (patch) | |
| tree | 3604f9fd49bb4908708f3547e2bebf85ff8fd645 /generic/tclThread.c | |
| parent | 1a30606518e92959f2e122f4a99a1a1c499a15a6 (diff) | |
| download | tcl-fc49271c0a03ec5ed04419f535526f3d229929c4.zip tcl-fc49271c0a03ec5ed04419f535526f3d229929c4.tar.gz tcl-fc49271c0a03ec5ed04419f535526f3d229929c4.tar.bz2 | |
Draft fix for a potential race condition in the new Tcl_MutexUnlockAndFinalize API. Not yet tested.
Diffstat (limited to 'generic/tclThread.c')
| -rw-r--r-- | generic/tclThread.c | 11 |
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(); } |
