[vlc-commits] tcp: simplify poll timeout

Rémi Denis-Courmont git at videolan.org
Tue Nov 7 17:55:44 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov  7 18:54:37 2017 +0200| [b24505edc138cf050039f048a98c4b6c07bd697a] | committer: Rémi Denis-Courmont

tcp: simplify poll timeout

This is the same logic as the TLS code now.

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

 src/network/tcp.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/network/tcp.c b/src/network/tcp.c
index 01e80844d5..f03a716899 100644
--- a/src/network/tcp.c
+++ b/src/network/tcp.c
@@ -165,26 +165,19 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
 
             ufd.fd = fd;
             ufd.events = POLLOUT;
-            if (timeout > 0)
-                deadline = mdate() + timeout;
+            deadline = mdate() + timeout;
 
             do
             {
-                int ms = -1;
+                mtime_t now = mdate();
 
                 if (vlc_killed())
                     goto next_ai;
 
-                if (deadline != VLC_TS_INVALID)
-                {
-                    ms = (deadline - mdate()) / (CLOCK_FREQ / 1000);
-                    if (ms < 0)
-                        ms = 0;
-                    if (ms > INT_MAX)
-                        ms = INT_MAX;
-                }
+                if (now > deadline)
+                    now = deadline;
 
-                val = vlc_poll_i11e(&ufd, 1, ms);
+                val = vlc_poll_i11e(&ufd, 1, (deadline - now) / 1000);
             }
             while (val == -1 && errno == EINTR);
 



More information about the vlc-commits mailing list