Commit 2f66c696 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tls: poll and timeout during handshake (fixes #7533)

parent 6c5a0639
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_POLL
# include <poll.h>
#endif
#include <assert.h>
#include <vlc_common.h> #include <vlc_common.h>
#include "libvlc.h" #include "libvlc.h"
...@@ -203,9 +208,29 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd, ...@@ -203,9 +208,29 @@ vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
if (session == NULL) if (session == NULL)
return NULL; return NULL;
mtime_t deadline = mdate ();
deadline += var_InheritInteger (crd, "ipv4-timeout") * 1000;
struct pollfd ufd[1];
ufd[0].fd = fd;
int val; int val;
do while ((val = vlc_tls_SessionHandshake (session, host, service)) > 0)
val = vlc_tls_SessionHandshake (session, host, service); {
mtime_t now = mdate ();
if (now > deadline)
now = deadline;
assert (val <= 2);
ufd[0] .events = (val == 1) ? POLLIN : POLLOUT;
if (poll (ufd, 1, (deadline - now) / 1000) == 0)
{
msg_Err (session, "TLS client session handshake timeout");
val = -1;
break;
}
}
while (val > 0); while (val > 0);
if (val != 0) if (val != 0)
......
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