gnutls: Allow closing a connection cleanly if handshake fails
authorStef Walter <stefw@gnome.org>
Thu, 29 Nov 2012 10:01:45 +0000 (11:01 +0100)
committerStef Walter <stefw@gnome.org>
Thu, 29 Nov 2012 22:04:11 +0000 (23:04 +0100)
Only set the internal ever_handshaked flag if the handshake was
successful. Otherwise using g_io_stream_close() after a handshake
failure results in an internal gnutls error.

https://bugzilla.gnome.org/show_bug.cgi?id=689260

tls/gnutls/gtlsconnection-gnutls.c

index 2603532..e67329d 100644 (file)
@@ -1082,12 +1082,15 @@ handshake_thread (GTask        *task,
   END_GNUTLS_IO (gnutls, G_IO_IN | G_IO_OUT, ret,
                 _("Error performing TLS handshake: %s"), &error);
 
-  gnutls->priv->ever_handshaked = TRUE;
-
   if (error)
-    g_task_return_error (task, error);
+    {
+      g_task_return_error (task, error);
+    }
   else
-    g_task_return_boolean (task, TRUE);
+    {
+      gnutls->priv->ever_handshaked = TRUE;
+      g_task_return_boolean (task, TRUE);
+    }
 }
 
 static GTlsCertificate *