[glib-networking/wip/pwithnall/dtls: 8/13] gnutls: Fix DTLS handshaking when packets are lost
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/wip/pwithnall/dtls: 8/13] gnutls: Fix DTLS handshaking when packets are lost
- Date: Thu, 2 Nov 2017 13:32:56 +0000 (UTC)
commit 415e737451bd8ebd61043b3d5eebe644e132ac87
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 | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 145c3a4..0968a15 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -1378,7 +1378,15 @@ 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);
+ {
+ /* Return EAGAIN while handshaking so that GnuTLS handles retries for us
+ * internally in its handshaking code. */
+ 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))
@@ -1410,7 +1418,7 @@ g_tls_connection_gnutls_pull_func (gnutls_transport_ptr_t transport_data,
ret = g_datagram_based_receive_messages (gnutls->priv->base_socket,
&message, 1, 0,
- gnutls->priv->read_timeout,
+ gnutls->priv->handshaking ? 0 : gnutls->priv->read_timeout,
gnutls->priv->read_cancellable,
&gnutls->priv->read_error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]