From f85e345a9e0f6cd78e69092a55adfacb911f89bc Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 25 Nov 2013 18:03:08 +0100 Subject: [PATCH] manager: as soon as we know we're going to stop, clear DBus connection So that the ObjectManager interface doesn't try to signal about e.g. interface removals; see: https://bugzilla.gnome.org/show_bug.cgi?id=715157. --- src/main.c | 7 +++++++ src/mm-manager.c | 21 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 4af28be2..78b3245f 100644 --- a/src/main.c +++ b/src/main.c @@ -44,6 +44,10 @@ static gboolean quit_cb (gpointer user_data) { mm_info ("Caught signal, shutting down..."); + + if (manager) + g_object_set (manager, MM_MANAGER_CONNECTION, NULL, NULL); + if (loop) g_idle_add ((GSourceFunc) g_main_loop_quit, loop); else @@ -100,6 +104,9 @@ name_lost_cb (GDBusConnection *connection, else mm_warn ("Could not acquire the '%s' service name", name); + if (manager) + g_object_set (manager, MM_MANAGER_CONNECTION, NULL, NULL); + g_main_loop_quit (loop); } diff --git a/src/mm-manager.c b/src/mm-manager.c index 5c048510..8c7969ee 100644 --- a/src/mm-manager.c +++ b/src/mm-manager.c @@ -789,11 +789,28 @@ set_property (GObject *object, MMManagerPrivate *priv = MM_MANAGER (object)->priv; switch (prop_id) { - case PROP_CONNECTION: - if (priv->connection) + case PROP_CONNECTION: { + gboolean had_connection = FALSE; + + if (priv->connection) { + had_connection = TRUE; g_object_unref (priv->connection); + } priv->connection = g_value_dup_object (value); + /* Propagate connection loss to subobjects */ + if (had_connection && !priv->connection) { + if (priv->object_manager) { + mm_dbg ("Stopping connection in object manager server"); + g_dbus_object_manager_server_set_connection (priv->object_manager, NULL); + } + if (priv->test_skeleton && + g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (priv->test_skeleton))) { + mm_dbg ("Stopping connection in test skeleton"); + g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (priv->test_skeleton)); + } + } break; + } case PROP_AUTO_SCAN: priv->auto_scan = g_value_get_boolean (value); break;