Commit d824b1ac authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

ws2_32: Improve implementation of get_poll_results.

parent 4b7ec826
......@@ -4386,36 +4386,37 @@ static void release_poll_fds( const WS_fd_set *readfds, const WS_fd_set *writefd
static int get_poll_results( WS_fd_set *readfds, WS_fd_set *writefds, WS_fd_set *exceptfds,
const struct pollfd *fds )
{
unsigned int exceptfds_off = (readfds ? readfds->fd_count : 0) + (writefds ? writefds->fd_count : 0);
unsigned int i, j = 0, k, total = 0;
const struct pollfd *poll_writefds = fds + (readfds ? readfds->fd_count : 0);
const struct pollfd *poll_exceptfds = poll_writefds + (writefds ? writefds->fd_count : 0);
unsigned int i, k, total = 0;
if (readfds)
{
for (i = k = 0; i < readfds->fd_count; i++, j++)
for (i = k = 0; i < readfds->fd_count; i++)
{
if (fds[j].revents ||
(readfds==writefds && (fds[readfds->fd_count+i].revents & POLLOUT) &&
!(fds[readfds->fd_count+i].revents & POLLHUP)) ||
(readfds==exceptfds && fds[exceptfds_off+i].revents))
if (fds[i].revents ||
(readfds == writefds && (poll_writefds[i].revents & POLLOUT) && !(poll_writefds[i].revents & POLLHUP)) ||
(readfds == exceptfds && poll_exceptfds[i].revents))
readfds->fd_array[k++] = readfds->fd_array[i];
}
readfds->fd_count = k;
total += k;
}
if (writefds && writefds!=readfds)
if (writefds && writefds != readfds)
{
for (i = k = 0; i < writefds->fd_count; i++, j++)
if (((fds[j].revents & POLLOUT) && !(fds[j].revents & POLLHUP)) ||
(writefds==exceptfds && fds[exceptfds_off+i].revents))
for (i = k = 0; i < writefds->fd_count; i++)
{
if (((poll_writefds[i].revents & POLLOUT) && !(poll_writefds[i].revents & POLLHUP)) ||
(writefds == exceptfds && poll_exceptfds[i].revents))
writefds->fd_array[k++] = writefds->fd_array[i];
}
writefds->fd_count = k;
total += k;
}
if (exceptfds && exceptfds!=readfds && exceptfds!=writefds)
if (exceptfds && exceptfds != readfds && exceptfds != writefds)
{
for (i = k = 0; i < exceptfds->fd_count; i++)
if (fds[exceptfds_off+i].revents) exceptfds->fd_array[k++] = exceptfds->fd_array[i];
if (poll_exceptfds[i].revents) exceptfds->fd_array[k++] = exceptfds->fd_array[i];
exceptfds->fd_count = k;
total += k;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment