[glib-networking/mcatanzaro/#15] 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] gnutls: discard queued data after interrupted writes
- Date: Mon, 19 Aug 2019 14:20:42 +0000 (UTC)
commit 1e03cde0b5d89f31715d9aeaf335f1ef5a15f5e1
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 4e883a7..f9a3af4 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 resent 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]