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 | ec8ad17e258e9758c10c5266ed7d4c4291b3a43b (patch) | |
tree | 3604f9fd49bb4908708f3547e2bebf85ff8fd645 /generic/tclThread.c | |
parent | b96efa9cbb68cfff7b6df11f8905b5719eaf7570 (diff) | |
download | tcl-ec8ad17e258e9758c10c5266ed7d4c4291b3a43b.zip tcl-ec8ad17e258e9758c10c5266ed7d4c4291b3a43b.tar.gz tcl-ec8ad17e258e9758c10c5266ed7d4c4291b3a43b.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(); } |