[glib-networking] gnutls: Don't hang trying to handshake, if early close
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib-networking] gnutls: Don't hang trying to handshake, if early close
- Date: Thu, 29 Nov 2012 22:23:26 +0000 (UTC)
commit 58fd3d5355f09d2480dfb69a446bf7018ef07914
Author: Stef Walter <stefw gnome org>
Date: Thu Nov 29 13:51:46 2012 +0100
gnutls: Don't hang trying to handshake, if early close
When closing a connection before the handshake, the GTlsConnectionGnutls
code would try to do a handshake. Fix this, and test for it.
https://bugzilla.gnome.org/show_bug.cgi?id=689271
tls/gnutls/gtlsconnection-gnutls.c | 3 ++-
tls/tests/connection.c | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/tls/gnutls/gtlsconnection-gnutls.c b/tls/gnutls/gtlsconnection-gnutls.c
index e67329d..b1d4d52 100644
--- a/tls/gnutls/gtlsconnection-gnutls.c
+++ b/tls/gnutls/gtlsconnection-gnutls.c
@@ -524,7 +524,8 @@ claim_op (GTlsConnectionGnutls *gnutls,
return FALSE;
}
- if (op != G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE)
+ if (op != G_TLS_CONNECTION_GNUTLS_OP_HANDSHAKE &&
+ op != G_TLS_CONNECTION_GNUTLS_OP_CLOSE)
{
if (gnutls->priv->need_handshake)
{
diff --git a/tls/tests/connection.c b/tls/tests/connection.c
index 37ed5a8..0768a46 100644
--- a/tls/tests/connection.c
+++ b/tls/tests/connection.c
@@ -885,6 +885,26 @@ test_simultaneous_sync (TestConnection *test,
}
static void
+test_close_immediately (TestConnection *test,
+ gconstpointer data)
+{
+ GIOStream *connection;
+ GError *error = NULL;
+
+ connection = start_async_server_and_connect_to_it (test, G_TLS_AUTHENTICATION_NONE);
+ test->client_connection = g_tls_client_connection_new (connection, test->identity, &error);
+ g_assert_no_error (error);
+ g_object_unref (connection);
+
+ /*
+ * At this point the server won't get a chance to run. But regardless
+ * closing should not wait on the server, trying to handshake or something.
+ */
+ if (!g_io_stream_close (test->client_connection, NULL, NULL))
+ g_assert_not_reached ();
+}
+
+static void
test_simultaneous_sync_rehandshake (TestConnection *test,
gconstpointer data)
{
@@ -930,6 +950,8 @@ main (int argc,
setup_connection, test_simultaneous_async_rehandshake, teardown_connection);
g_test_add ("/tls/connection/simultaneous-sync-rehandshake", TestConnection, NULL,
setup_connection, test_simultaneous_sync_rehandshake, teardown_connection);
+ g_test_add ("/tls/connection/close-immediately", TestConnection, NULL,
+ setup_connection, test_close_immediately, teardown_connection);
ret = g_test_run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]