There are several bugs in poll(): - poll() must return 0 if no descriptor is ready and the timer expires. It works correctly if all descriptors are non-negative. Otherwise poll() returns the count of negative descriptors which is wrong. - The implementation of poll() must call cygwin_select() even if all descriptors are invalid. Currently poll() returns immediately - and ignores any timer value. The return value is wrong again because of the bug above. - If the timer expires revents must be 0 and must not be set to anything else like POLLNVAL, POLLHUP or whatever. - If cygwin_select() returns -1 revents must be 0 and must not be set to POLLERR. Eg. a signal interrupting poll() doesn't mean an error has occured for a TCP connection. - If an error is pending revents must be set to POLLERR. - The implementation of poll() has a local variable called open_fds that isn't used. I can't see why this variable exists.
I've attached three files: - newpoll.cc has a new implementation of poll() which fixes the bugs. - patch.cc is the patch. - polltest.c is a testcase. I rebuilt cygwin1.dll with my poll() function so there should be no problems when compiling. Boris
newpoll.cc
Description: Binary data
patch.cc
Description: Binary data
polltest.c
Description: Binary data
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/