[libsoup] connection: clear the cancellable before completing the GTask



commit 3c601cdc2adfa3184cfb978df4dc8fd7db53ba32
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Tue Nov 10 17:20:20 2020 +0100

    connection: clear the cancellable before completing the GTask
    
    The session calls soup_connection_disconnect() on the GTask callback in
    case of error. At that point cancellable should be NULL already, since
    the operation completed.
    
    Fixes #206

 libsoup/soup-connection.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index 9597097b..e6a79bf7 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -553,17 +553,17 @@ connect_async_ready_cb (GSocketClient *client,
 
         connection = g_socket_client_connect_finish (client, result, &error);
         if (!connection) {
+               g_clear_object (&priv->cancellable);
                 g_task_return_error (task, error);
                 g_object_unref (task);
-                g_clear_object (&priv->cancellable);
                 return;
         }
 
         if (!soup_connection_connected (conn, connection, &error)) {
+               g_clear_object (&priv->cancellable);
                 g_task_return_error (task, error);
                 g_object_unref (task);
                 g_object_unref (connection);
-                g_clear_object (&priv->cancellable);
                 return;
         }
 
@@ -743,9 +743,9 @@ soup_connection_tunnel_handshake_async (SoupConnection     *conn,
 
         tls_connection = new_tls_connection (conn, G_SOCKET_CONNECTION (priv->connection), &error);
         if (!tls_connection) {
+               g_clear_object (&priv->cancellable);
                 g_task_return_error (task, error);
                 g_object_unref (task);
-                g_clear_object (&priv->cancellable);
                 return;
         }
 


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