[vlc-devel] [PATCH 3/3] poll: only read and reset the WSAEvent for the socket that was signaled

Steve Lhomme robux4 at videolabs.io
Wed Jul 13 18:50:22 CEST 2016


---
 compat/poll.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/compat/poll.c b/compat/poll.c
index a6dadb9..efe82ed 100644
--- a/compat/poll.c
+++ b/compat/poll.c
@@ -217,8 +217,17 @@ int poll(struct pollfd *fds, unsigned nfds, int timeout)
         {
             WSANETWORKEVENTS ne;
 
+            if (ret != WSA_WAIT_EVENT_0 + i)
+                continue; /* don't read events for other sockets than the first found */
+
             if (WSAEnumNetworkEvents(fds[i].fd, evts[i], &ne))
-                memset(&ne, 0, sizeof (ne));
+            {
+                /* unhook the event before we close it, otherwise the socket may fail */
+                WSAEventSelect(fds[i].fd, evts[i], 0);
+                continue;
+            }
+
+            /* unhook the event before we close it, otherwise the socket may fail */
             WSAEventSelect(fds[i].fd, evts[i], 0);
 
             if (ne.lNetworkEvents & FD_CONNECT)
-- 
2.8.2



More information about the vlc-devel mailing list