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

Rafaël Carré funman at videolan.org
Thu Feb 7 16:41:10 CET 2013


Le 07/02/2013 16:08, Ludovic Fauvet a écrit :
> Based on the gnutls_handshake manual the function must be called again
> until it returns 0 (or a fatal error).

     The non-fatal errors such as `GNUTLS_E_AGAIN' and
     `GNUTLS_E_INTERRUPTED' interrupt the handshake procedure, which
     should be later be resumed.  Call this function again, until it
     returns 0; cf.  `gnutls_record_get_direction()' and
     `gnutls_error_is_fatal()'.

But we already return when meeting those non-fatal errrors.

> ---
>  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..f964cde 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);
> +    while(1)
> +    {
> +        val = gnutls_handshake (sys->session);
> +        if ((val == GNUTLS_E_AGAIN) || (val == GNUTLS_E_INTERRUPTED))
> +            return 1 + gnutls_record_get_direction (sys->session);
> +        if (val < 0 && gnutls_error_is_fatal(val) == 0)
> +            msg_Warn (session, "TLS handshake: %s", gnutls_strerror (val));
> +        else
> +            break;
> +    }
>  
>      if (val < 0)
>      {
> 




More information about the vlc-devel mailing list