mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 16:26:12 +08:00
* poll.cc (poll): Return count of fds with events instead of total
event count.
This commit is contained in:
parent
5642c35aae
commit
d1f3668837
@ -1,3 +1,9 @@
|
||||
2007-12-13 Craig MacGregor <cmacgreg@gmail.com>
|
||||
Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* poll.cc (poll): Return count of fds with events instead of total
|
||||
event count.
|
||||
|
||||
2007-12-13 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* string.h: Guard cygwin internal string function definitions with
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* poll.cc. Implements poll(2) via usage of select(2) call.
|
||||
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
|
||||
Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
@ -76,9 +76,14 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
if (invalid_fds)
|
||||
return invalid_fds;
|
||||
|
||||
int ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds, timeout < 0 ? NULL : &tv);
|
||||
int ret = cygwin_select (max_fd + 1, read_fds, write_fds, except_fds,
|
||||
timeout < 0 ? NULL : &tv);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
|
||||
if (ret > 0)
|
||||
/* Set revents fields and count fds with non-zero revents fields for
|
||||
return value. */
|
||||
ret = 0;
|
||||
for (unsigned int i = 0; i < nfds; ++i)
|
||||
{
|
||||
if (fds[i].fd >= 0)
|
||||
@ -112,6 +117,8 @@ poll (struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
fds[i].revents |= POLLPRI;
|
||||
}
|
||||
}
|
||||
if (fds[i].revents)
|
||||
++ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user