summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhobbs <hobbs>2000-04-24 23:32:13 (GMT)
committerhobbs <hobbs>2000-04-24 23:32:13 (GMT)
commite38c8fdd49d388071ea563f8a0a8fada898eefd9 (patch)
tree50b19f689249d3877bc99eca02c7d44395247a21
parentf01e61ac300d8ce4e10dc60e0510a2409a969bf6 (diff)
downloadtcl-e38c8fdd49d388071ea563f8a0a8fada898eefd9.zip
tcl-e38c8fdd49d388071ea563f8a0a8fada898eefd9.tar.gz
tcl-e38c8fdd49d388071ea563f8a0a8fada898eefd9.tar.bz2
* unix/tclUnixNotfy.c (Tcl_FinalizeNotifier, NotifierThreadProc):
added write of 'q' into triggerPipe for notifier in threaded case, so that Tcl doesn't hang when children are still running [Bug: 4139] * unix/tclUnixThrd.c (Tcl_MutexLock): minor comment fixes.
-rw-r--r--ChangeLog46
-rw-r--r--unix/tclUnixNotfy.c40
-rw-r--r--unix/tclUnixThrd.c4
3 files changed, 58 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 5da8d38..5315917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,26 +1,34 @@
+2000-04-24 Jeff Hobbs <hobbs@scriptics.com>
+
+ * unix/tclUnixNotfy.c (Tcl_FinalizeNotifier, NotifierThreadProc):
+ added write of 'q' into triggerPipe for notifier in threaded case,
+ so that Tcl doesn't hang when children are still running [Bug: 4139]
+
+ * unix/tclUnixThrd.c (Tcl_MutexLock): minor comment fixes.
+
2000-04-23 Jim Ingham <jingham@cygnus.com>
- These changes make some error handling marginally better for Mac sockets. It is
- still somewhat flakey, however.
-
- * mac/tclMacSock.c (TcpClose): Add timeouts to the close - these don't seem to
- be honored, however.
- * Use a separate PB for the release, since an async connect socket will still
- be using the original buffer.
- * Make sure TCPRelease returns noErr before freeing the recvBuff. If the call
- returns an error, then the buffer is not right.
- * mac/tclMacSocket.c (CreateSocket): Add timeouts to the async create. These
- don't seem to trigger, however. Sigh...
- * mac/tclMacSocket.c (WaitForSocketEvent): If an TCP_ASYNC_CONNECT socket errors
- out, then return EWOULDBLOCK & error out.
- * mac/tclMacSock.c: (NotifyRoutine) Added a NotifyRoutine for experimenting
- with MacTCP.
-
+ These changes make some error handling marginally better for Mac
+ sockets. It is still somewhat flakey, however.
+
+ * mac/tclMacSock.c (TcpClose): Add timeouts to the close - these
+ don't seem to be honored, however.
+ Use a separate PB for the release, since an async connect socket
+ will still be using the original buffer.
+ Make sure TCPRelease returns noErr before freeing the recvBuff.
+ If the call returns an error, then the buffer is not right.
+ * mac/tclMacSock.c (CreateSocket): Add timeouts to the async
+ create. These don't seem to trigger, however. Sigh...
+ * mac/tclMacSock.c (WaitForSocketEvent): If an TCP_ASYNC_CONNECT
+ socket errors out, then return EWOULDBLOCK & error out.
+ * mac/tclMacSock.c (NotifyRoutine): Added a NotifyRoutine for
+ experimenting with MacTCP.
+
2000-04-22 Jim Ingham <jingham@cygnus.com>
- * library/package.tcl (tclPkgUnknown): Fixed a typo in the Mac package
- search part of tclPkgUnknown.
-
+ * library/package.tcl (tclPkgUnknown): Fixed a typo in the Mac package
+ search part of tclPkgUnknown.
+
2000-04-21 Sandeep Tamhankar <sandeep@scriptics.com>
* library/http2.1/http.tcl: Fixed a newly introduced bug where if
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 7d63228..f376746 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.9 2000/04/09 16:04:20 kupries Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.10 2000/04/24 23:32:13 hobbs Exp $
*/
#include "tclInt.h"
@@ -264,7 +264,20 @@ Tcl_FinalizeNotifier(clientData)
if (triggerPipe < 0) {
panic("Tcl_FinalizeNotifier: notifier pipe not initialized");
}
+
+ /*
+ * Send "q" message to the notifier thread so that it will
+ * terminate. The notifier will return from its call to select()
+ * and notice that a "q" message has arrived, it will then close
+ * its side of the pipe and terminate its thread. Note the we can
+ * 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]
+ */
+ write(triggerPipe, "q", 1);
close(triggerPipe);
+
Tcl_ConditionWait(&notifierCV, &notifierMutex, NULL);
}
@@ -963,10 +976,10 @@ NotifierThreadProc(clientData)
Tcl_ConditionNotify(&tsdPtr->waitCV);
if (tsdPtr->onList) {
/*
- * Remove the ThreadSpecificData structure of this thread
- * from the waiting list. This prevents us from continuously
- * spining on select until the other threads runs and
- * services the file event.
+ * Remove the ThreadSpecificData structure of this
+ * thread from the waiting list. This prevents us from
+ * continuously spining on select until the other
+ * threads runs and services the file event.
*/
if (tsdPtr->prevPtr) {
@@ -991,13 +1004,18 @@ NotifierThreadProc(clientData)
* to avoid a race condition we only read one at a time.
*/
- if ((masks[index] & bit) && (read(receivePipe, buf, 1) == 0)) {
- /*
- * Someone closed the write end of the pipe so we need to
- * shut down the notifier thread.
- */
+ if (masks[index] & bit) {
+ i = read(receivePipe, buf, 1);
- break;
+ if ((i == 0) || ((i == 1) && (buf[0] == 'q'))) {
+ /*
+ * Someone closed the write end of the pipe or sent us a
+ * Quit message [Bug: 4139] and then closed the write end
+ * of the pipe so we need to shut down the notifier thread.
+ */
+
+ break;
+ }
}
}
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index f4a5dca..16e2315 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -356,7 +356,7 @@ Tcl_MutexLock(mutexPtr)
MASTER_LOCK;
if (*mutexPtr == NULL) {
/*
- * Double inside master lock check to avoid a race.
+ * Double inside master lock check to avoid a race condition.
*/
pmutexPtr = (pthread_mutex_t *)ckalloc(sizeof(pthread_mutex_t));
@@ -374,7 +374,7 @@ Tcl_MutexLock(mutexPtr)
/*
*----------------------------------------------------------------------
*
- * TclpMutexUnlock --
+ * Tcl_MutexUnlock --
*
* This procedure is invoked to unlock a mutex. The mutex must
* have been locked by Tcl_MutexLock.