[vlc-commits] win32: do not get stuck in poll() with infinite timeout

Rémi Denis-Courmont git at videolan.org
Mon Feb 4 18:15:39 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Feb  4 19:14:33 2013 +0200| [576c05f07f93e47c543c1e1d4946269394d3899b] | committer: Rémi Denis-Courmont

win32: do not get stuck in poll() with infinite timeout

This really should be fixed more properly.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=576c05f07f93e47c543c1e1d4946269394d3899b
---

 include/vlc_threads.h |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 337ded4..1197b55 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -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)
 



More information about the vlc-commits mailing list