]> git.sesse.net Git - vlc/commitdiff
win32: do not get stuck in poll() with infinite timeout
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 4 Feb 2013 17:14:33 +0000 (19:14 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 4 Feb 2013 17:14:33 +0000 (19:14 +0200)
This really should be fixed more properly.

include/vlc_threads.h

index 337ded42df55f4a879a01b3ac011b6b6c5115b7b..1197b55cd486cd605633dbdbfe5f2e014c560068 100644 (file)
@@ -388,18 +388,22 @@ struct vlc_cleanup_t
 /* poll() with cancellation */
 static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
 {
-    vlc_testcancel ();
+    int val;
 
-    while (timeout > 50)
+    do
     {
-        int val = poll (fds, nfds, 50);
-        if (val != 0)
-            return val;
-        timeout -= 50;
+        int ugly_timeout = 50;
+        if (timeout >= 50)
+            timeout -= 50;
+        else if ((unsigned)timeout < 50u)
+            ugly_timeout = timeout;
+
         vlc_testcancel ();
+        val = poll (fds, nfds, ugly_timeout);
     }
+    while (val == 0 && timeout != 0);
 
-    return poll (fds, nfds, timeout);
+    return val;
 }
 # define poll(u,n,t) vlc_poll(u, n, t)