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

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

(cherry picked from commit 2f66c69631cc461ac8619d1f14561fd13a59dc08)

Conflicts:
	src/network/tls.c
parent 299dd463
......@@ -30,6 +30,11 @@
# include "config.h"
#endif
#ifdef HAVE_POLL
# include <poll.h>
#endif
#include <assert.h>
#include <vlc_common.h>
#include "libvlc.h"
......@@ -181,11 +186,29 @@ vlc_tls_ClientCreate (vlc_object_t *obj, int fd, const char *hostname)
return NULL;
}
/* TODO: do this directly in the TLS plugin */
mtime_t deadline = mdate ();
deadline += var_InheritInteger (obj, "ipv4-timeout") * 1000;
struct pollfd ufd[1];
ufd[0].fd = fd;
int val;
do
val = cl->handshake (cl);
while (val > 0);
while ((val = cl->handshake (cl)) > 0)
{
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 (cl, "TLS client session handshake timeout");
val = -1;
break;
}
}
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