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
97378bb6a5Fix [040586323610be22f8617962377324f4ddc9bc02|0405863236]: wrong field checked in struct pollfd in TclUnixWaitForFile check-in2017-12-10 14:35:02
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.