From 6c79f46f137a8134f5f1b2670d78e6434cbcfc6c Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 19 May 2008 16:13:31 +0000 Subject: [PATCH] 2008-05-19 Dan Williams Make the system settings service exit when the bus goes away. Since it's a bus-activated service, it's lifetime is limited to the bus that activated it (rh #444976). * system-settings/src/Makefile.am system-settings/src/nm-system-config-hal-manager-private.h - Remove nm-system-config-hal-manager-private.h * system-settings/src/nm-system-config-hal-manager.c - (nm_system_config_hal_manager_reinit_dbus, nm_system_config_hal_manager_deinit_dbus): remove * system-settings/src/main.c - (dbus_reconnect): remove - (dbus_cleanup): don't tell the HAL manager to deinit dbus - (destroy_cb): just quit when the bus goes away - (start_dbus_service, dbus_init): simplify - (main): destroy the wired devices hash table after destroying the HAL manager so we don't have to disconnect signals from the HAL manager git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3674 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 23 +++++++ system-settings/src/Makefile.am | 1 - system-settings/src/main.c | 61 ++++--------------- .../nm-system-config-hal-manager-private.h | 34 ----------- .../src/nm-system-config-hal-manager.c | 16 +---- 5 files changed, 37 insertions(+), 98 deletions(-) delete mode 100644 system-settings/src/nm-system-config-hal-manager-private.h diff --git a/ChangeLog b/ChangeLog index ff245e8d8f..6087d7c87d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2008-05-19 Dan Williams + + Make the system settings service exit when the bus goes away. Since it's + a bus-activated service, it's lifetime is limited to the bus that activated + it (rh #444976). + + * system-settings/src/Makefile.am + system-settings/src/nm-system-config-hal-manager-private.h + - Remove nm-system-config-hal-manager-private.h + + * system-settings/src/nm-system-config-hal-manager.c + - (nm_system_config_hal_manager_reinit_dbus, + nm_system_config_hal_manager_deinit_dbus): remove + + * system-settings/src/main.c + - (dbus_reconnect): remove + - (dbus_cleanup): don't tell the HAL manager to deinit dbus + - (destroy_cb): just quit when the bus goes away + - (start_dbus_service, dbus_init): simplify + - (main): destroy the wired devices hash table after destroying + the HAL manager so we don't have to disconnect signals from the + HAL manager + 2008-05-15 Tambet Ingo Move crypto functions from nm-applet to libnm-util. diff --git a/system-settings/src/Makefile.am b/system-settings/src/Makefile.am index 0fbf652190..a2025871da 100644 --- a/system-settings/src/Makefile.am +++ b/system-settings/src/Makefile.am @@ -19,7 +19,6 @@ nm_system_settings_SOURCES = \ nm-system-config-interface.h \ nm-system-config-hal-manager.c \ nm-system-config-hal-manager.h \ - nm-system-config-hal-manager-private.h \ nm-sysconfig-connection.c \ nm-sysconfig-connection.h \ sha1.c \ diff --git a/system-settings/src/main.c b/system-settings/src/main.c index 4c7856d942..16eb325357 100644 --- a/system-settings/src/main.c +++ b/system-settings/src/main.c @@ -44,7 +44,6 @@ #include "dbus-settings.h" #include "nm-system-config-hal-manager.h" -#include "nm-system-config-hal-manager-private.h" #include "nm-system-config-interface.h" typedef struct { @@ -53,7 +52,6 @@ typedef struct { DBusGProxy *bus_proxy; NMSystemConfigHalManager *hal_mgr; - gboolean started; NMSysconfigSettings *settings; GMainLoop *loop; @@ -62,8 +60,9 @@ typedef struct { } Application; +NMSystemConfigHalManager *nm_system_config_hal_manager_get (DBusGConnection *g_connection); + static gboolean dbus_init (Application *app); -static void dbus_cleanup (Application *app); static gboolean start_dbus_service (Application *app); static void destroy_cb (DBusGProxy *proxy, gpointer user_data); static void device_added_cb (DBusGProxy *proxy, const char *udi, NMDeviceType devtype, gpointer user_data); @@ -400,23 +399,6 @@ device_removed_cb (DBusGProxy *proxy, const char *udi, NMDeviceType devtype, gpo /******************************************************************/ -static gboolean -dbus_reconnect (gpointer user_data) -{ - Application *app = (Application *) user_data; - - if (dbus_init (app)) { - if (start_dbus_service (app)) { - g_message ("reconnected to the system bus."); - nm_system_config_hal_manager_reinit_dbus (app->hal_mgr, app->g_connection); - return TRUE; - } - } - - dbus_cleanup (app); - return FALSE; -} - static void dbus_cleanup (Application *app) { @@ -431,10 +413,6 @@ dbus_cleanup (Application *app) g_object_unref (app->bus_proxy); app->bus_proxy = NULL; } - - nm_system_config_hal_manager_deinit_dbus (app->hal_mgr); - - app->started = FALSE; } static void @@ -443,10 +421,8 @@ destroy_cb (DBusGProxy *proxy, gpointer user_data) Application *app = (Application *) user_data; /* Clean up existing connection */ - g_warning ("disconnected by the system bus."); - dbus_cleanup (app); - - g_timeout_add (3000, dbus_reconnect, app); + g_warning ("disconnected from the system bus, exiting."); + g_main_loop_quit (app->loop); } static gboolean @@ -455,11 +431,6 @@ start_dbus_service (Application *app) int request_name_result; GError *err = NULL; - if (app->started) { - g_warning ("Service has already started."); - return FALSE; - } - if (!dbus_g_proxy_call (app->bus_proxy, "RequestName", &err, G_TYPE_STRING, NM_DBUS_SERVICE_SYSTEM_SETTINGS, G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE, @@ -469,23 +440,17 @@ start_dbus_service (Application *app) g_warning ("Could not acquire the NetworkManagerSystemSettings service.\n" " Message: '%s'", err->message); g_error_free (err); - goto out; + return FALSE; } if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { g_warning ("Could not acquire the NetworkManagerSystemSettings service " "as it is already taken. Return: %d", request_name_result); - goto out; + return FALSE; } - app->started = TRUE; - -out: - if (!app->started) - dbus_cleanup (app); - - return app->started; + return TRUE; } static gboolean @@ -513,16 +478,12 @@ dbus_init (Application *app) "org.freedesktop.DBus"); if (!app->bus_proxy) { g_warning ("Could not get the DBus object!"); - goto error; + return FALSE; } g_signal_connect (app->bus_proxy, "destroy", G_CALLBACK (destroy_cb), app); return TRUE; - -error: - dbus_cleanup (app); - return FALSE; } static gboolean @@ -682,11 +643,13 @@ main (int argc, char **argv) g_main_loop_run (app->loop); - g_hash_table_destroy (app->wired_devices); - g_object_unref (app->settings); g_object_unref (app->hal_mgr); + g_hash_table_destroy (app->wired_devices); + + dbus_cleanup (app); + if (!debug) logging_shutdown (); diff --git a/system-settings/src/nm-system-config-hal-manager-private.h b/system-settings/src/nm-system-config-hal-manager-private.h deleted file mode 100644 index cb7d551e27..0000000000 --- a/system-settings/src/nm-system-config-hal-manager-private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008 Dan Williams - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -/* *** Not to be used by system settings service plugins *** */ - -#ifndef NM_SYSTEM_CONFIG_HAL_MANAGER_PRIVATE_H -#define NM_SYSTEM_CONFIG_HAL_MANAGER_PRIVATE_H - -#include "nm-system-config-hal-manager.h" - -NMSystemConfigHalManager *nm_system_config_hal_manager_get (DBusGConnection *g_connection); - -void nm_system_config_hal_manager_reinit_dbus (NMSystemConfigHalManager *manager, - DBusGConnection *g_connection); - -void nm_system_config_hal_manager_deinit_dbus (NMSystemConfigHalManager *manager); - -#endif /* NM_SYSTEM_CONFIG_HAL_MANAGER_PRIVATE_H */ diff --git a/system-settings/src/nm-system-config-hal-manager.c b/system-settings/src/nm-system-config-hal-manager.c index ce05d2033d..19342d2735 100644 --- a/system-settings/src/nm-system-config-hal-manager.c +++ b/system-settings/src/nm-system-config-hal-manager.c @@ -26,7 +26,8 @@ #include "nm-marshal.h" #include "nm-dbus-glib-types.h" #include "nm-system-config-hal-manager.h" -#include "nm-system-config-hal-manager-private.h" + +NMSystemConfigHalManager *nm_system_config_hal_manager_get (DBusGConnection *g_connection); #define NUM_DEVICE_TYPES DEVICE_TYPE_CDMA @@ -320,19 +321,6 @@ nm_system_config_hal_manager_class_init (NMSystemConfigHalManagerClass *manager_ G_TYPE_UINT); } -void -nm_system_config_hal_manager_reinit_dbus (NMSystemConfigHalManager *manager, - DBusGConnection *g_connection) -{ - init_dbus (manager, g_connection); -} - -void -nm_system_config_hal_manager_deinit_dbus (NMSystemConfigHalManager *manager) -{ - cleanup_dbus (manager); -} - typedef struct { NMDeviceType devtype; GSList **list;