diff options
author | vasiljevic <zv@archiware.com> | 2005-07-01 10:29:03 (GMT) |
---|---|---|
committer | vasiljevic <zv@archiware.com> | 2005-07-01 10:29:03 (GMT) |
commit | 2e00bc9eeeb1aa604c2a184cce678d2051240998 (patch) | |
tree | 6909002d8041e04a49744b9259ec2ff48f0fcb60 | |
parent | 74e4d540d750139af207b77b2f32347ec287b2c9 (diff) | |
download | tcl-2e00bc9eeeb1aa604c2a184cce678d2051240998.zip tcl-2e00bc9eeeb1aa604c2a184cce678d2051240998.tar.gz tcl-2e00bc9eeeb1aa604c2a184cce678d2051240998.tar.bz2 |
Protect against spurious wake-ups while waiting on the condition variable
when tearing down the notifier thread [Bug# 1222872].
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | unix/tclUnixNotfy.c | 14 |
2 files changed, 14 insertions, 6 deletions
@@ -1,3 +1,9 @@ +2005-07-01 Zoran Vasiljevic <vasiljevic@users.sourceforge.net> + + * unix/tclUnixNotfy.c: protect against spurious wake-ups while + waiting on the condition variable when tearing down the notifier + thread [Bug# 1222872]. + 2005-06-28 Mo DeJong <mdejong@users.sourceforge.net> * generic/tclExecute.c (TclExecuteByteCode): diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 1976433..b0052d4 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclUnixNotfy.c,v 1.26 2005/06/01 09:38:05 dkf Exp $ + * RCS: @(#) $Id: tclUnixNotfy.c,v 1.27 2005/07/01 10:29:12 vasiljevic Exp $ */ #ifndef HAVE_COREFOUNDATION /* Darwin/Mac OS X CoreFoundation notifier @@ -273,7 +273,7 @@ Tcl_FinalizeNotifier(clientData) */ if (notifierCount == 0) { - int result, ignored; + int result; if (triggerPipe < 0) { Tcl_Panic("Tcl_FinalizeNotifier: notifier pipe not initialized"); } @@ -286,13 +286,15 @@ Tcl_FinalizeNotifier(clientData) * not just close the pipe and check for EOF in the notifier * thread because if a background child process was created with * exec, select() would not register the EOF on the pipe until the - * child processes had terminated. [Bug: 4139] + * child processes had terminated. [Bug: 4139] [Bug: 1222872] */ + write(triggerPipe, "q", 1); close(triggerPipe); - - Tcl_ConditionWait(¬ifierCV, ¬ifierMutex, NULL); - result = Tcl_JoinThread(notifierThread, &ignored); + while(triggerPipe >= 0) { + Tcl_ConditionWait(¬ifierCV, ¬ifierMutex, NULL); + } + result = Tcl_JoinThread(notifierThread, NULL); if (result) { Tcl_Panic("Tcl_FinalizeNotifier: unable to join notifier thread"); } |