[glib-networking/mcatanzaro/#15: 20/20] gnutls: discard queued data after interrupted writes
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/#15: 20/20] gnutls: discard queued data after interrupted writes
- Date: Sun, 1 Sep 2019 23:04:09 +0000 (UTC)
commit 6be22b13b6958896e6b6b462e0e521aaf82f4c59
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sun Aug 18 21:42:32 2019 -0500
gnutls: discard queued data after interrupted writes
If a write is interrupted, GnuTLS buffers the data in order to send it
again during the next write. E.g. you can call gnutls_write() with NULL
data and 0 size to resend the buffered data, or you can call it again
with exactly the same parameters, and either way will be fine. But
GOutputStream works differently. Applications using GOutputStream expect
they need to explicitly resend any data that wasn't queued and expect to
be able to resend different data if they so choose.
Per Dan:
"""
GTlsOutputStreamGnutls is violating the semantics of GOutputStream; if
it claims to have not written the data, then it can't write it later
without being asked to. GTlsConnectionGnutls needs to hide this behavior
from higher levels somehow.
"""
Fixes #15
tls/gnutls/gtlsconnection-gnutls.c | 6 ++++++
1 file changed, 6 insertions(+)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index 2ea627b..27b1456 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -1020,6 +1020,12 @@ g_tls_connection_gnutls_write (GTlsConnectionBase *tls,
ret = gnutls_record_send (priv->session, buffer, count);
END_GNUTLS_IO (gnutls, G_IO_OUT, ret, status, _("Error writing data to TLS socket"), error);
+ /* GnuTLS will resend interrupted writes unless we discard its send queue.
+ * But GOutputStream requires explicit resend when interrupted.
+ */
+ if (ret == GNUTLS_E_INTERRUPTED || ret == GNUTLS_E_AGAIN)
+ gnutls_record_discard_queued (priv->session);
+
*nwrote = MAX (ret, 0);
return status;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]