This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

poll() bugs and patch


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

Attachment: newpoll.cc
Description: Binary data

Attachment: patch.cc
Description: Binary data

Attachment: 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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]