[glib-networking/mcatanzaro/session-resumption: 2/13] Always call complete_handshake() even if handshake failed



commit ce58eb560dd26602519f27a86350d36786cae530
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Tue Sep 24 14:28:06 2019 -0500

    Always call complete_handshake() even if handshake failed
    
    Otherwise we might not notify accepted-cas as the tests expect. This is
    really minor, but good to do since they could have changed even though
    the handshake failed.
    
    Same for negotiated-protocol.

 tls/base/gtlsconnection-base.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/tls/base/gtlsconnection-base.c b/tls/base/gtlsconnection-base.c
index 5cfa85f..c72c3ec 100644
--- a/tls/base/gtlsconnection-base.c
+++ b/tls/base/gtlsconnection-base.c
@@ -1566,13 +1566,6 @@ finish_handshake (GTlsConnectionBase  *tls,
           g_mutex_unlock (&priv->verify_certificate_mutex);
         }
 
-      if (tls_class->complete_handshake)
-        tls_class->complete_handshake (tls, &priv->negotiated_protocol, &my_error);
-
-      if (g_strcmp0 (original_negotiated_protocol, priv->negotiated_protocol) != 0)
-        g_object_notify (G_OBJECT (tls), "negotiated-protocol");
-      g_free (original_negotiated_protocol);
-
       /* FIXME: Return an error from the handshake thread instead. */
       if (priv->peer_certificate && !priv->peer_certificate_accepted)
         {
@@ -1581,6 +1574,16 @@ finish_handshake (GTlsConnectionBase  *tls,
         }
     }
 
+  if (tls_class->complete_handshake)
+    {
+      /* If we already have an error, ignore further errors. */
+      tls_class->complete_handshake (tls, &priv->negotiated_protocol, my_error ? NULL : &my_error);
+
+      if (g_strcmp0 (original_negotiated_protocol, priv->negotiated_protocol) != 0)
+        g_object_notify (G_OBJECT (tls), "negotiated-protocol");
+    }
+  g_free (original_negotiated_protocol);
+
   if (my_error && priv->started_handshake)
     priv->handshake_error = g_error_copy (my_error);
 


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