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.
This commit is contained in:
Aleksander Morgado
2013-11-25 18:03:08 +01:00
parent 247a945950
commit f85e345a9e
2 changed files with 26 additions and 2 deletions

View File

@@ -44,6 +44,10 @@ static gboolean
quit_cb (gpointer user_data) quit_cb (gpointer user_data)
{ {
mm_info ("Caught signal, shutting down..."); mm_info ("Caught signal, shutting down...");
if (manager)
g_object_set (manager, MM_MANAGER_CONNECTION, NULL, NULL);
if (loop) if (loop)
g_idle_add ((GSourceFunc) g_main_loop_quit, loop); g_idle_add ((GSourceFunc) g_main_loop_quit, loop);
else else
@@ -100,6 +104,9 @@ name_lost_cb (GDBusConnection *connection,
else else
mm_warn ("Could not acquire the '%s' service name", name); 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); g_main_loop_quit (loop);
} }

View File

@@ -789,11 +789,28 @@ set_property (GObject *object,
MMManagerPrivate *priv = MM_MANAGER (object)->priv; MMManagerPrivate *priv = MM_MANAGER (object)->priv;
switch (prop_id) { switch (prop_id) {
case PROP_CONNECTION: case PROP_CONNECTION: {
if (priv->connection) gboolean had_connection = FALSE;
if (priv->connection) {
had_connection = TRUE;
g_object_unref (priv->connection); g_object_unref (priv->connection);
}
priv->connection = g_value_dup_object (value); 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; break;
}
case PROP_AUTO_SCAN: case PROP_AUTO_SCAN:
priv->auto_scan = g_value_get_boolean (value); priv->auto_scan = g_value_get_boolean (value);
break; break;