[glib-networking/wip/nacho/openssl: 4/12] openssl: fix readwrite_after_connection_destroyed test



commit 1c54da67401cf6918810d255d923601f176c2306
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Tue Sep 11 10:55:06 2018 +0200

    openssl: fix readwrite_after_connection_destroyed test

 tls/base/gtlsinputstream-base.c  | 9 ++++++++-
 tls/base/gtlsoutputstream-base.c | 9 ++++++++-
 tls/tests/connection.c           | 5 -----
 3 files changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/tls/base/gtlsinputstream-base.c b/tls/base/gtlsinputstream-base.c
index c560e12..49542fd 100644
--- a/tls/base/gtlsinputstream-base.c
+++ b/tls/base/gtlsinputstream-base.c
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "gtlsinputstream-base.h"
 
+#include <glib/gi18n.h>
+
 static void g_tls_input_stream_base_pollable_iface_init (GPollableInputStreamInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GTlsInputStreamBase, g_tls_input_stream_base, G_TYPE_INPUT_STREAM,
@@ -66,7 +68,12 @@ g_tls_input_stream_base_read (GInputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->priv->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, count, TRUE,
diff --git a/tls/base/gtlsoutputstream-base.c b/tls/base/gtlsoutputstream-base.c
index 3b4a4d6..a4c87eb 100644
--- a/tls/base/gtlsoutputstream-base.c
+++ b/tls/base/gtlsoutputstream-base.c
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "gtlsoutputstream-base.h"
 
+#include <glib/gi18n.h>
+
 static void g_tls_output_stream_base_pollable_iface_init (GPollableOutputStreamInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GTlsOutputStreamBase, g_tls_output_stream_base, G_TYPE_OUTPUT_STREAM,
@@ -66,7 +68,12 @@ g_tls_output_stream_base_write (GOutputStream  *stream,
   gssize ret;
 
   conn = g_weak_ref_get (&tls_stream->priv->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, count, TRUE,
                                      cancellable, error);
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index 9cc880a..94c1e94 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -1981,11 +1981,6 @@ test_readwrite_after_connection_destroyed (TestConnection *test,
   unsigned char buffer[1];
   GError *error = NULL;
 
-#ifdef BACKEND_IS_OPENSSL
-  g_test_skip ("this needs more research on openssl");
-  return;
-#endif
-
   g_test_bug ("792219");
 
   connection = start_async_server_and_connect_to_it (test, G_TLS_AUTHENTICATION_REQUESTED);


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