vlc/vlc-2.0 | branch: master | Rémi Denis-Courmont <r...@remlab.net> | Sun Sep 30 18:18:37 2012 +0300| [b0255011ce7d06f323c63b85242b0fae39c39a50] | committer: Rémi Denis-Courmont
tls: poll and timeout during handshake (fixes #7533) (cherry picked from commit 2f66c69631cc461ac8619d1f14561fd13a59dc08) Conflicts: src/network/tls.c > http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=b0255011ce7d06f323c63b85242b0fae39c39a50 --- src/network/tls.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/network/tls.c b/src/network/tls.c index 93892aa..db723af 100644 --- a/src/network/tls.c +++ b/src/network/tls.c @@ -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) { _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org http://mailman.videolan.org/listinfo/vlc-commits