[gnome-session] main: exit gracefully when disconnected from the session bus
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] main: exit gracefully when disconnected from the session bus
- Date: Mon, 4 Jun 2012 22:38:55 +0000 (UTC)
commit 34c380508516f8a2f81b68d189b24fedb05870ea
Author: William Jon McCann <jmccann redhat com>
Date: Mon Jun 4 18:19:46 2012 -0400
main: exit gracefully when disconnected from the session bus
This fixes a problem where all hell breaks loose if we
lose the bus.
https://bugzilla.gnome.org/show_bug.cgi?id=608409
gnome-session/main.c | 31 ++++++++++++++++++++++++-------
1 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/gnome-session/main.c b/gnome-session/main.c
index b16db5e..7a648ab 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -54,6 +54,10 @@ static gboolean show_version = FALSE;
static gboolean debug = FALSE;
static gboolean please_fail = FALSE;
+static DBusGProxy *bus_proxy = NULL;
+
+static void shutdown_cb (gpointer data);
+
static void
on_bus_name_lost (DBusGProxy *bus_proxy,
const char *name,
@@ -128,7 +132,6 @@ acquire_name_on_proxy (DBusGProxy *bus_proxy,
static gboolean
acquire_name (void)
{
- DBusGProxy *bus_proxy;
GError *error;
DBusGConnection *connection;
@@ -141,10 +144,22 @@ acquire_name (void)
/* not reached */
}
- bus_proxy = dbus_g_proxy_new_for_name (connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS);
+ bus_proxy = dbus_g_proxy_new_for_name_owner (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ gsm_util_init_error (TRUE,
+ "Could not connect to session bus: %s",
+ error->message);
+ /* not reached */
+ }
+
+ g_signal_connect_swapped (bus_proxy,
+ "destroy",
+ G_CALLBACK (shutdown_cb),
+ NULL);
if (! acquire_name_on_proxy (bus_proxy, GSM_DBUS_NAME) ) {
gsm_util_init_error (TRUE,
@@ -153,8 +168,6 @@ acquire_name (void)
/* not reached */
}
- g_object_unref (bus_proxy);
-
return TRUE;
}
@@ -378,6 +391,10 @@ main (int argc, char **argv)
g_object_unref (client_store);
}
+ if (bus_proxy != NULL) {
+ g_object_unref (bus_proxy);
+ }
+
gdm_log_shutdown ();
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]