Commit 8bda7d72 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix previous commit (untested)

parent acade544
...@@ -46,6 +46,8 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) ...@@ -46,6 +46,8 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
WSAEVENT phEvents[nfds]; WSAEVENT phEvents[nfds];
DWORD val; DWORD val;
vlc_testcancel ();
for (unsigned i = 0; i < nfds; i++) for (unsigned i = 0; i < nfds; i++)
{ {
long events = FD_CLOSE; long events = FD_CLOSE;
...@@ -62,25 +64,25 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) ...@@ -62,25 +64,25 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
WSAEventSelect (fds[i].fd, phEvents[i], events); WSAEventSelect (fds[i].fd, phEvents[i], events);
} }
int ret = 0, n;
switch (WaitForMultipleObjectsEx (nfds, phEvents, FALSE, timeout, TRUE)) switch (WaitForMultipleObjectsEx (nfds, phEvents, FALSE, timeout, TRUE))
{ {
case WAIT_IO_COMPLETION: case WAIT_IO_COMPLETION:
WSASetLastError (WSAEINTR); WSASetLastError (WSAEINTR);
return -1; ret = -1;
break;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
return 0; ret = 0;
} break;
default:
int n = 0, err = 0;
for (unsigned i = 0; i < nfds; i++) for (unsigned i = 0; i < nfds; i++)
{ {
WSANETWORKEVENTS events; WSANETWORKEVENTS events;
err = WSAEnumNetworkEvents (fds[i].fd, phEvents[i], &events); if (WSAEnumNetworkEvents (fds[i].fd, phEvents[i], &events))
WSACloseEvent (phEvents[i]);
if (err)
{ {
fds[i].revents |= POLLNVAL; fds[i].revents |= POLLNVAL;
ret = -1;
continue; continue;
} }
if (events.lNetworkEvents & FD_CLOSE) if (events.lNetworkEvents & FD_CLOSE)
...@@ -100,6 +102,14 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) ...@@ -100,6 +102,14 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
if (fds[i].events) if (fds[i].events)
n++; n++;
} }
return err ? -1 : n; if (ret == 0)
ret = n;
}
for (unsigned i = 0; i < nfds; i++)
WSACloseEvent (phEvents[i]);
vlc_testcancel ();
return ret;
} }
#endif /* WIN32 */ #endif /* WIN32 */
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