From 024b92cb1e7bd2653beee2d010f1baf39010cacc Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Tue, 10 Jul 2012 18:28:48 +0000
Subject: [Bug 3541646] Don't panic on triggerPipe overrun

---
 ChangeLog           |  4 ++++
 unix/tclUnixNotfy.c | 10 +++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8b8e49a..704fd06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2012-07-10  Jan Nijtmans  <nijtmans@users.sf.net>
+
+	* unix/tclUnixNotfy.c: [Bug 3541646] Don't panic on triggerPipe overrun
+
 2012-07-10  Donal K. Fellows  <dkf@users.sf.net>
 
 	* win/tclWinSock.c (InitializeHostName): Corrected logic that
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 904c9db..42cc7be 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -340,7 +340,7 @@ Tcl_FinalizeNotifier(
 	 */
 
 	if (write(triggerPipe, "q", 1) != 1) {
-		    Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe");
+	    Tcl_Panic("Tcl_FinalizeNotifier: unable to write q to triggerPipe");
 	}
 	close(triggerPipe);
 	while(triggerPipe >= 0) {
@@ -879,8 +879,8 @@ Tcl_WaitForEvent(
 	waitingListPtr = tsdPtr;
 	tsdPtr->onList = 1;
 
-	if (write(triggerPipe, "", 1) != 1) {
-		Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
+	if ((write(triggerPipe, "", 1) == -1) && (errno != EAGAIN)) {
+	    Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
 	}
     }
 
@@ -942,8 +942,8 @@ Tcl_WaitForEvent(
 	}
 	tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
 	tsdPtr->onList = 0;
-	if (write(triggerPipe, "", 1) != 1) {
-		Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
+	if ((write(triggerPipe, "", 1) == -1) && (errno != EAGAIN)) {
+	    Tcl_Panic("Tcl_WaitForEvent: unable to write to triggerPipe");
 	}
     }
 
-- 
cgit v0.12