GDBus: make use of reliable async cancellation
authorRyan Lortie <desrt@desrt.ca>
Tue, 13 Mar 2012 20:41:57 +0000 (16:41 -0400)
committerDavid Zeuthen <davidz@redhat.com>
Thu, 15 Mar 2012 18:01:35 +0000 (14:01 -0400)
Call g_simple_async_result_set_check_cancellable() after all
GSimpleAsyncResult creation in order to take advantage of the new
reliable cancellation feature.

The guarantee of reliable cancellation fixes a bug in dbusmenu (which
was already assuming that cancellation was reliable).  See this bug:
https://bugs.launchpad.net/ubuntu/+source/libdbusmenu/+bug/953562

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

Signed-off-by: David Zeuthen <davidz@redhat.com>
gio/gdbusaddress.c
gio/gdbusconnection.c
gio/gdbusprivate.c
gio/gdbusproxy.c

index feb098b..77aff12 100644 (file)
@@ -856,6 +856,7 @@ g_dbus_address_get_stream (const gchar         *address,
                                    callback,
                                    user_data,
                                    g_dbus_address_get_stream);
+  g_simple_async_result_set_check_cancellable (res, cancellable);
   data = g_new0 (GetStreamData, 1);
   data->address = g_strdup (address);
   g_simple_async_result_set_op_res_gpointer (res,
index 1fce45f..7a4a08a 100644 (file)
@@ -1246,6 +1246,7 @@ g_dbus_connection_flush (GDBusConnection     *connection,
                                       callback,
                                       user_data,
                                       g_dbus_connection_flush);
+  g_simple_async_result_set_check_cancellable (simple, cancellable);
   g_simple_async_result_run_in_thread (simple,
                                        flush_in_thread_func,
                                        G_PRIORITY_DEFAULT,
@@ -1459,6 +1460,7 @@ g_dbus_connection_close (GDBusConnection     *connection,
                                       callback,
                                       user_data,
                                       g_dbus_connection_close);
+  g_simple_async_result_set_check_cancellable (simple, cancellable);
   _g_dbus_worker_close (connection->worker, cancellable, simple);
   g_object_unref (simple);
 }
@@ -1916,6 +1918,7 @@ g_dbus_connection_send_message_with_reply_unlocked (GDBusConnection     *connect
                                       callback,
                                       user_data,
                                       g_dbus_connection_send_message_with_reply);
+  g_simple_async_result_set_check_cancellable (simple, cancellable);
 
   if (g_cancellable_is_cancelled (cancellable))
     {
@@ -5340,6 +5343,7 @@ g_dbus_connection_call_internal (GDBusConnection        *connection,
   state->simple = g_simple_async_result_new (G_OBJECT (connection),
                                              callback, user_data,
                                              g_dbus_connection_call_internal);
+  g_simple_async_result_set_check_cancellable (state->simple, cancellable);
   state->method_name = g_strjoin (".", interface_name, method_name, NULL);
 
   if (reply_type == NULL)
@@ -6859,6 +6863,7 @@ g_bus_get (GBusType             bus_type,
                                       callback,
                                       user_data,
                                       g_bus_get);
+  g_simple_async_result_set_check_cancellable (simple, cancellable);
 
   error = NULL;
   connection = get_uninitialized_connection (bus_type, cancellable, &error);
index 3aa71cf..4b31fa7 100644 (file)
@@ -191,6 +191,7 @@ _g_socket_read_with_control_messages (GSocket                 *socket,
                                             callback,
                                             user_data,
                                             _g_socket_read_with_control_messages);
+  g_simple_async_result_set_check_cancellable (data->simple, cancellable);
 
   if (!g_socket_condition_check (socket, G_IO_IN))
     {
index 906faa4..a7c56d1 100644 (file)
@@ -1695,6 +1695,7 @@ async_initable_init_second_async (GAsyncInitable      *initable,
                                             callback,
                                             user_data,
                                             NULL);
+  g_simple_async_result_set_check_cancellable (data->simple, cancellable);
 
   /* Check name ownership asynchronously - possibly also start the service */
   if (proxy->priv->name == NULL)
@@ -1840,6 +1841,7 @@ get_connection_cb (GObject       *source_object,
                                           data->callback,
                                           data->user_data,
                                           NULL);
+      g_simple_async_result_set_check_cancellable (simple, data->cancellable);
       g_simple_async_result_take_error (simple, error);
       g_simple_async_result_complete_in_idle (simple);
       g_object_unref (simple);
@@ -2698,6 +2700,7 @@ g_dbus_proxy_call_internal (GDBusProxy          *proxy,
                                       callback,
                                       user_data,
                                       g_dbus_proxy_call_internal);
+  g_simple_async_result_set_check_cancellable (simple, cancellable);
 
   G_LOCK (properties_lock);