From e3c7fdd7a47264c584f3f16e37d903a7d1f36f76 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 13 Mar 2012 16:41:57 -0400 Subject: [PATCH] GDBus: make use of reliable async cancellation 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 --- gio/gdbusaddress.c | 1 + gio/gdbusconnection.c | 5 +++++ gio/gdbusprivate.c | 1 + gio/gdbusproxy.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/gio/gdbusaddress.c b/gio/gdbusaddress.c index feb098b..77aff12 100644 --- a/gio/gdbusaddress.c +++ b/gio/gdbusaddress.c @@ -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, diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 1fce45f..7a4a08a 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -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); diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index 3aa71cf..4b31fa7 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -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)) { diff --git a/gio/gdbusproxy.c b/gio/gdbusproxy.c index 906faa4..a7c56d1 100644 --- a/gio/gdbusproxy.c +++ b/gio/gdbusproxy.c @@ -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); -- 2.7.4