[glib-networking/mcatanzaro/base-rebase: 26/45] base: TLS streams should expect to outlast the GTlsConnection
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking/mcatanzaro/base-rebase: 26/45] base: TLS streams should expect to outlast the GTlsConnection
- Date: Mon, 13 May 2019 16:57:10 +0000 (UTC)
commit c4a5007841d38955316eae187570ea2f4656571c
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Apr 7 16:28:50 2019 -0500
base: TLS streams should expect to outlast the GTlsConnection
This is a port of e5dac2ba5f21fc53f1461992224cf56e4a345cdb. Previously,
only the first portion of the commit had been adopted by the base
classes.
tls/base/gtlsinputstream.c | 20 ++++++++++++++------
tls/base/gtlsoutputstream.c | 20 ++++++++++++++------
2 files changed, 28 insertions(+), 12 deletions(-)
---
diff --git a/tls/base/gtlsinputstream.c b/tls/base/gtlsinputstream.c
index ea2fb99..bc4ebcf 100644
--- a/tls/base/gtlsinputstream.c
+++ b/tls/base/gtlsinputstream.c
@@ -94,7 +94,8 @@ g_tls_input_stream_pollable_is_readable (GPollableInputStream *pollable)
gboolean ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, FALSE);
+ if (conn == NULL)
+ return FALSE;
ret = g_tls_connection_base_check (conn, G_IO_IN);
@@ -111,7 +112,12 @@ g_tls_input_stream_pollable_create_source (GPollableInputStream *pollable,
GSource *ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, NULL);
+ if (conn == NULL)
+ {
+ ret = g_idle_source_new ();
+ g_source_set_name (ret, "[glib-networking] g_tls_input_stream_pollable_create_source dummy source");
+ return ret;
+ }
ret = g_tls_connection_base_create_source (conn, G_IO_IN, cancellable);
g_object_unref (conn);
@@ -129,7 +135,12 @@ g_tls_input_stream_pollable_read_nonblocking (GPollableInputStream *pollable,
gssize ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, -1);
+ if (conn == NULL)
+ {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
+ _("Connection is closed"));
+ return -1;
+ }
ret = g_tls_connection_base_read (conn, buffer, size,
0 /* non-blocking */, NULL, error);
@@ -149,9 +160,6 @@ g_tls_input_stream_close (GInputStream *stream,
conn = g_weak_ref_get (&tls_stream->weak_conn);
- /* Special case here because this is called by the finalize
- * of the main GTlsConnection object.
- */
if (conn == NULL)
return TRUE;
diff --git a/tls/base/gtlsoutputstream.c b/tls/base/gtlsoutputstream.c
index 6cf7316..30f9d76 100644
--- a/tls/base/gtlsoutputstream.c
+++ b/tls/base/gtlsoutputstream.c
@@ -93,7 +93,8 @@ g_tls_output_stream_pollable_is_writable (GPollableOutputStream *pollable)
gboolean ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, FALSE);
+ if (conn == NULL)
+ return FALSE;
ret = g_tls_connection_base_check (conn, G_IO_OUT);
@@ -111,7 +112,12 @@ g_tls_output_stream_pollable_create_source (GPollableOutputStream *pollable,
GSource *ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, NULL);
+ if (conn == NULL)
+ {
+ ret = g_idle_source_new ();
+ g_source_set_name (ret, "[glib-networking] g_tls_output_stream_pollable_create_source dummy source");
+ return ret;
+ }
ret = g_tls_connection_base_create_source (conn,
G_IO_OUT,
@@ -131,7 +137,12 @@ g_tls_output_stream_pollable_write_nonblocking (GPollableOutputStream *pollable
gssize ret;
conn = g_weak_ref_get (&tls_stream->weak_conn);
- g_return_val_if_fail (conn != NULL, -1);
+ if (conn == NULL)
+ {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_CLOSED,
+ _("Connection is closed"));
+ return -1;
+ }
ret = g_tls_connection_base_write (conn, buffer, size,
0 /* non-blocking */, NULL, error);
@@ -151,9 +162,6 @@ g_tls_output_stream_close (GOutputStream *stream,
conn = g_weak_ref_get (&tls_stream->weak_conn);
- /* Special case here because this is called by the finalize
- * of the main GTlsConnection object.
- */
if (conn == NULL)
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]