4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-22 00:38:06 +08:00

Patch from Frederic Devernay <Frederic.Devernay@sophia.inria.fr>:

* poll.cc (poll): Call cygwin_select() if any fd is valid.
This commit is contained in:
Corinna Vinschen 2001-10-17 18:52:06 +00:00
parent c711831918
commit e34027611a
2 changed files with 11 additions and 8 deletions

View File

@ -1,3 +1,7 @@
2001-10-16 Frederic Devernay <Frederic.Devernay@sophia.inria.fr>
* poll.cc (poll): Call cygwin_select() if any fd is valid.
2001-10-16 Corinna Vinschen <corinna@vinschen.de> 2001-10-16 Corinna Vinschen <corinna@vinschen.de>
* fhandler_raw.cc (fhandler_dev_raw::open): Eliminate compatibility * fhandler_raw.cc (fhandler_dev_raw::open): Eliminate compatibility

View File

@ -51,10 +51,12 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
memset (write_fds, 0, fds_size); memset (write_fds, 0, fds_size);
memset (except_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) for (unsigned int i = 0; i < nfds; ++i)
if (!cygheap->fdtab.not_open (fds[i].fd)) if (!cygheap->fdtab.not_open (fds[i].fd))
{ {
valid_fds = true;
fds[i].revents = 0;
FD_SET (fds[i].fd, open_fds); FD_SET (fds[i].fd, open_fds);
if (fds[i].events & POLLIN) if (fds[i].events & POLLIN)
FD_SET (fds[i].fd, read_fds); 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); FD_SET (fds[i].fd, except_fds);
} }
else else
invalid_fds = true; fds[i].revents = POLLNVAL;
int ret = 0; int ret = 0;
if (!invalid_fds) if (valid_fds)
ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds, ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds,
timeout < 0 ? NULL : &tv); timeout < 0 ? NULL : &tv);
for (unsigned int i = 0; i < nfds; ++i) for (unsigned int i = 0; i < nfds; ++i)
{ {
if (!FD_ISSET (fds[i].fd, open_fds)) if (fds[i].revents == POLLNVAL && ret >= 0)
{ ret++;
fds[i].revents = POLLNVAL;
ret++;
}
else if (cygheap->fdtab.not_open(fds[i].fd)) else if (cygheap->fdtab.not_open(fds[i].fd))
fds[i].revents = POLLHUP; fds[i].revents = POLLHUP;
else if (ret < 0) else if (ret < 0)