[vlc-commits] tcp: simplify poll timeout

Rémi Denis-Courmont git at videolan.org
Tue Nov 7 18:04:59 CET 2017


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov  7 18:54:37 2017 +0200| [858e517febcdfbce9aba777261cb97827e45473e] | 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=858e517febcdfbce9aba777261cb97827e45473e
---

 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