[vlc-commits] compat: poll: work around event loss on WIN32

Thomas Guillem git at videolan.org
Fri Feb 23 08:29:19 CET 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 22 10:15:17 2018 +0100| [776c8d73fb67f474cd2064d2f2d00b4cb7b20403] | committer: Thomas Guillem

compat: poll: work around event loss on WIN32

Signed-off-by: Steve Lhomme <robux4 at videolabs.io>
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
(cherry picked from commit 3e0d833a3f8d87a6aa94bd226e94387ebd95a4e4)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=776c8d73fb67f474cd2064d2f2d00b4cb7b20403
---

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

diff --git a/compat/poll.c b/compat/poll.c
index fa94c932cc..8020f7dbff 100644
--- a/compat/poll.c
+++ b/compat/poll.c
@@ -109,7 +109,7 @@ int (poll) (struct pollfd *fds, unsigned nfds, int timeout)
 # include <windows.h>
 # include <winsock2.h>
 
-int poll(struct pollfd *fds, unsigned nfds, int timeout)
+static int poll_compat(struct pollfd *fds, unsigned nfds, int timeout)
 {
     DWORD to = (timeout >= 0) ? (DWORD)timeout : INFINITE;
 
@@ -251,4 +251,21 @@ int poll(struct pollfd *fds, unsigned nfds, int timeout)
     }
     return count;
 }
+
+int poll(struct pollfd *fds, unsigned nfds, int timeout)
+{
+    if (timeout == -1)
+    {
+        /* HACK: In some cases, we lose some events because events are
+         * destroyed and recreated only when we need to poll. In order to work
+         * arround this issue, we try to call the poll compat function every
+         * 100ms (in case of infinite timeout). */
+        int ret;
+        while ((ret = poll_compat(fds, nfds, 100)) == 0);
+        return ret;
+    }
+    else
+        return poll_compat(fds, nfds, timeout);
+}
+
 #endif



More information about the vlc-commits mailing list