Mail Archives: cygwin/2001/10/17/04:13:42
Hello,
Jason's patch
(http://www.cygwin.com/ml/cygwin-patches/2001-q3/msg00109.html)
had the following problems:
- it used FD_ISSET with a fd that could possibly be completely out of
range... Sun RPC for example uses fd=-1 in its poll() calls (which
made my server crash when the client quits).
- even when there's _some_ invalid fds, cygwin_select() should be
called. But it should not be called if _all_ are invalid.
- the return value from cygwin_select should not be modified if it's
negative (can it be negative?).
- In brief, it only worked if all fds were valid, or if all were
invalid but within the valid range.
Here's another try:
Index: poll.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/poll.cc,v
retrieving revision 1.20
diff -u -r1.20 poll.cc
--- poll.cc 2001/10/01 04:10:07 1.20
+++ poll.cc 2001/10/15 12:43:29
@@ -51,10 +51,12 @@
memset (write_fds, 0, fds_size);
memset (except_fds, 0, fds_size);
- bool invalid_fds = false;
+ bool valid_fds = false;
for (unsigned int i = 0; i < nfds; ++i)
if (!cygheap->fdtab.not_open (fds[i].fd))
{
+ valid_fds = true;
+ fds[i].revents = 0;
FD_SET (fds[i].fd, open_fds);
if (fds[i].events & POLLIN)
FD_SET (fds[i].fd, read_fds);
@@ -64,20 +66,17 @@
FD_SET (fds[i].fd, except_fds);
}
else
- invalid_fds = true;
+ fds[i].revents = POLLNVAL;
int ret = 0;
- if (!invalid_fds)
+ if (valid_fds)
ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds,
timeout < 0 ? NULL : &tv);
for (unsigned int i = 0; i < nfds; ++i)
{
- if (!FD_ISSET (fds[i].fd, open_fds))
- {
- fds[i].revents = POLLNVAL;
- ret++;
- }
+ if (fds[i].revents == POLLNVAL && ret >= 0)
+ ret++;
else if (cygheap->fdtab.not_open(fds[i].fd))
fds[i].revents = POLLHUP;
else if (ret < 0)
----- End forwarded message -----
--
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/
- Raw text -