diff options
author | carlosg <carlosg> | 2006-12-01 19:24:39 +0000 |
---|---|---|
committer | carlosg <carlosg> | 2006-12-01 19:24:39 +0000 |
commit | 154d417396810982fe125964a1f78b4555b05998 (patch) | |
tree | e2804e3da3deb9dd1cf1dea4a2650370c927bcec /dispatcher | |
parent | d574e39a718f1330f7a38667bb14b5f701ce8ef5 (diff) |
2006-12-01 Carlos Garnacho <carlosg@gnome.org>
* dispatcher/dispatcher.c: catch DBus errors, kill the private bus if
there was any fatal error.
Diffstat (limited to 'dispatcher')
-rw-r--r-- | dispatcher/dispatcher.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/dispatcher/dispatcher.c b/dispatcher/dispatcher.c index 388687d..f3721b5 100644 --- a/dispatcher/dispatcher.c +++ b/dispatcher/dispatcher.c @@ -233,6 +233,9 @@ static DBusConnection* get_private_bus (void) { DBusConnection *connection = NULL; + DBusError error; + + dbus_error_init (&error); if (!bus_pid) { @@ -255,14 +258,17 @@ get_private_bus (void) putenv (envvar); /* get a connection with the newly created bus */ - connection = dbus_bus_get (DBUS_BUS_SESSION, NULL); + connection = dbus_bus_get (DBUS_BUS_SESSION, &error); + + if (dbus_error_is_set (&error)) + g_critical (error.message); } return connection; } void -on_sigterm (gint signal) +kill_private_bus (gint signal) { /* terminate the private bus */ if (bus_pid) @@ -286,25 +292,30 @@ main (int argc, char *argv[]) dbus_error_init (&error); daemonize (); - signal (SIGTERM, on_sigterm); + signal (SIGTERM, kill_private_bus); session_connection = get_private_bus (); connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); if (!session_connection || !connection) - exit (-1); + { + kill_private_bus (0); + exit (-1); + } dbus_connection_set_exit_on_disconnect (connection, FALSE); dbus_connection_set_exit_on_disconnect (session_connection, FALSE); - dbus_bus_request_name (connection, DBUS_INTERFACE_STB, 0, &error); dbus_connection_add_filter (connection, dispatcher_filter_func, session_connection, NULL); + dbus_bus_request_name (connection, DBUS_INTERFACE_STB, 0, &error); + + if (dbus_error_is_set (&error)) + g_critical (error.message); + dbus_connection_setup_with_g_main (connection, NULL); dbus_connection_setup_with_g_main (session_connection, NULL); - /* FIXME: error checking */ - main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); |