Commit 858e517f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tcp: simplify poll timeout

This is the same logic as the TLS code now.
parent 806823ea
...@@ -165,26 +165,19 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port, ...@@ -165,26 +165,19 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
ufd.fd = fd; ufd.fd = fd;
ufd.events = POLLOUT; ufd.events = POLLOUT;
if (timeout > 0) deadline = mdate() + timeout;
deadline = mdate() + timeout;
do do
{ {
int ms = -1; mtime_t now = mdate();
if (vlc_killed()) if (vlc_killed())
goto next_ai; goto next_ai;
if (deadline != VLC_TS_INVALID) if (now > deadline)
{ now = deadline;
ms = (deadline - mdate()) / (CLOCK_FREQ / 1000);
if (ms < 0)
ms = 0;
if (ms > INT_MAX)
ms = INT_MAX;
}
val = vlc_poll_i11e(&ufd, 1, ms); val = vlc_poll_i11e(&ufd, 1, (deadline - now) / 1000);
} }
while (val == -1 && errno == EINTR); while (val == -1 && errno == EINTR);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment