Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-12-10
14:39 • Closed ticket [0405863236]: wrong field checked in struct pollfd in TclUnixWaitF... artifact: 185c6a5880 user: jan.nijtmans
14:35
Fix [040586323610be22f8617962377324f4ddc9bc02|0405863236]: wrong field checked in struct pollfd in T... check-in: 97378bb6a5 user: jan.nijtmans tags: core-8-branch
2017-12-09
19:03 • Ticket [0405863236] wrong field checked in struct pollfd in TclUnixWaitForFile</... artifact: cb63364f04 user: chw
2017-11-30
08:20 • New ticket [0405863236]. artifact: f895e7fff6 user: chw

wrong field checked in struct pollfd in TclUnixWaitForFile

Closed / Fixed040586323610be22f8617962377324f4ddc9bc02Created 9 years agoUpdated 9 years ago
Descriptionplain2017-11-30 08:20:14
In the new poll based UN*X notifier there seems to be a logic error
in the TclUnixWaitForFile function.

After calling poll the events field of struct pollfd is checked
for POLLIN et.al. but the returned events are reported in the
revents field according to the poll man page.
Referenced by1
chwplain2017-12-09 19:03:50
Index: unix/tclUnixNotfy.c
==================================================================
--- unix/tclUnixNotfy.c
+++ unix/tclUnixNotfy.c
@@ -530,17 +530,17 @@
 	    }
 	}
 	numFound = poll(pollFds, 1, pollTimeout);
 	if (numFound == 1) {
 	    result = 0;
-	    if (pollFds[0].events & (POLLIN | POLLHUP)) {
+	    if (pollFds[0].revents & (POLLIN | POLLHUP)) {
 		result |= TCL_READABLE;
 	    }
-	    if (pollFds[0].events & POLLOUT) {
+	    if (pollFds[0].revents & POLLOUT) {
 		result |= TCL_WRITABLE;
 	    }
-	    if (pollFds[0].events & POLLERR) {
+	    if (pollFds[0].revents & POLLERR) {
 		result |= TCL_EXCEPTION;
 	    }
 	    if (result) {
 		break;
 	    }
jan.nijtmansplain2017-12-10 14:39:21
Thank you Christian!  It's indeed a subtile difference, extremely difficult to catch in a test-case as it is very timing-sensitive. However, I think you are right!  Committed to core-8-branch and trunk
Log in (anonymous is fine) to add a comment.