poll() bugs and patch

Boris Schaeling boriss@web.de
Wed Mar 13 06:06:00 GMT 2002


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newpoll.cc
Type: application/octet-stream
Size: 2383 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20020313/121e163d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.cc
Type: application/octet-stream
Size: 3256 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20020313/121e163d/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: polltest.c
Type: application/octet-stream
Size: 999 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20020313/121e163d/attachment-0002.obj>
-------------- next part --------------
--
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/


More information about the Cygwin mailing list