[glib-networking/wip/pwithnall/dtls: 72/74] gnutls: Fix DTLS handshaking when packets are lost



commit 94fe47f1559523ad90ac3f6757e4bfe7e749a319
Author: Olivier CrĂȘte <olivier crete collabora com>
Date:   Wed Jan 6 21:58:41 2016 -0500

    gnutls: Fix DTLS handshaking when packets are lost
    
    During a handshake, the timeout is set to "-1", so blocking forever,
    this is wrong for DTLS, where the blocking should instead happen inside
    the pull_timeout function. Also, return EAGAIN during the handshake so
    that GnuTLS will do the re-tries for us internally and the re-sending as
    required.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697908

 tls/gnutls/gtlsconnection-gnutls.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 282cbe1..1be5d79 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -1361,7 +1361,13 @@ set_gnutls_error (GTlsConnectionGnutls *gnutls,
   if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
     gnutls_transport_set_errno (gnutls->priv->session, EINTR);
   else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
-    gnutls_transport_set_errno (gnutls->priv->session, EINTR);
+    {
+      if (gnutls->priv->base_socket &&
+          gnutls->priv->handshaking)
+        gnutls_transport_set_errno (gnutls->priv->session, EAGAIN);
+      else
+        gnutls_transport_set_errno (gnutls->priv->session, EINTR);
+    }
   else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_TIMED_OUT))
     gnutls_transport_set_errno (gnutls->priv->session, EINTR);
   else if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_MESSAGE_TOO_LARGE))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]