[vlc-commits] gnutls: retry handshake if it returns a non-fatal error

Ludovic Fauvet git at videolan.org
Fri Feb 8 13:26:08 CET 2013


vlc | branch: master | Ludovic Fauvet <etix at videolan.org> | Thu Feb  7 17:21:06 2013 +0100| [ca82afbfb7ee9a083d13c7861408e5759f2509cd] | committer: Jean-Baptiste Kempf

gnutls: retry handshake if it returns a non-fatal error

Based on the gnutls_handshake manual the function must be called again
until it returns 0 (or a fatal error).

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ca82afbfb7ee9a083d13c7861408e5759f2509cd
---

 modules/misc/gnutls.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/modules/misc/gnutls.c b/modules/misc/gnutls.c
index 312c682..e470280 100644
--- a/modules/misc/gnutls.c
+++ b/modules/misc/gnutls.c
@@ -229,9 +229,16 @@ static int gnutls_ContinueHandshake (vlc_tls_t *session, const char *host,
 #ifdef WIN32
     WSASetLastError (0);
 #endif
-    val = gnutls_handshake (sys->session);
-    if ((val == GNUTLS_E_AGAIN) || (val == GNUTLS_E_INTERRUPTED))
-        return 1 + gnutls_record_get_direction (sys->session);
+    do
+    {
+        val = gnutls_handshake (sys->session);
+        msg_Dbg (session, "TLS handshake: %s", gnutls_strerror (val));
+
+        if ((val == GNUTLS_E_AGAIN) || (val == GNUTLS_E_INTERRUPTED))
+            /* I/O event: return to caller's poll() loop */
+            return 1 + gnutls_record_get_direction (sys->session);
+    }
+    while (val < 0 && !gnutls_error_is_fatal (val));
 
     if (val < 0)
     {



More information about the vlc-commits mailing list