summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/poll.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-10-17 18:52:06 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-10-17 18:52:06 +0000
commite34027611aee68eb3e2467db874137f22ba5c204 (patch)
tree8af7b7a6d7d65a7a8f54d5fc0c648d265e1f3ebb /winsup/cygwin/poll.cc
parentc711831918b5b066e41aae33c2f043c05d8805e9 (diff)
downloadcygnal-e34027611aee68eb3e2467db874137f22ba5c204.tar.gz
cygnal-e34027611aee68eb3e2467db874137f22ba5c204.tar.bz2
cygnal-e34027611aee68eb3e2467db874137f22ba5c204.zip
Patch from Frederic Devernay <Frederic.Devernay@sophia.inria.fr>:
* poll.cc (poll): Call cygwin_select() if any fd is valid.
Diffstat (limited to 'winsup/cygwin/poll.cc')
-rw-r--r--winsup/cygwin/poll.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/winsup/cygwin/poll.cc b/winsup/cygwin/poll.cc
index ce28d0554..017d0e529 100644
--- a/winsup/cygwin/poll.cc
+++ b/winsup/cygwin/poll.cc
@@ -51,10 +51,12 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
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 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
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)