mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-09 23:40:33 +01:00
dbus: destroy singleton instance of NMDBusManager on exit
Don't have the singleton instance of NMDBusManager owned by the main function. Instead use NM_DEFINE_SINGLETON_DESTRUCTOR() which also logs what's happening.
This commit is contained in:
parent
e5a82e5698
commit
1208c0dd13
2 changed files with 6 additions and 8 deletions
|
|
@ -200,7 +200,6 @@ main (int argc, char *argv[])
|
|||
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
|
||||
gboolean success, show_version = FALSE;
|
||||
NMManager *manager = NULL;
|
||||
gs_unref_object NMDBusManager *dbus_mgr = NULL;
|
||||
gs_unref_object NMSettings *settings = NULL;
|
||||
gs_unref_object NMConfig *config = NULL;
|
||||
GError *error = NULL;
|
||||
|
|
@ -387,10 +386,6 @@ main (int argc, char *argv[])
|
|||
|
||||
nm_auth_manager_setup (nm_config_get_auth_polkit (config));
|
||||
|
||||
/* Initialize our DBus service & connection */
|
||||
dbus_mgr = nm_dbus_manager_get ();
|
||||
g_assert (dbus_mgr != NULL);
|
||||
|
||||
nm_dispatcher_init ();
|
||||
|
||||
settings = nm_settings_new (&error);
|
||||
|
|
@ -413,7 +408,7 @@ main (int argc, char *argv[])
|
|||
goto done;
|
||||
}
|
||||
|
||||
if (!nm_dbus_manager_get_connection (dbus_mgr)) {
|
||||
if (!nm_dbus_manager_get_connection (nm_dbus_manager_get ())) {
|
||||
#if HAVE_DBUS_GLIB_100
|
||||
nm_log_warn (LOGD_CORE, "Failed to connect to D-Bus; only private bus is available");
|
||||
#else
|
||||
|
|
@ -422,7 +417,7 @@ main (int argc, char *argv[])
|
|||
#endif
|
||||
} else {
|
||||
/* Start our DBus service */
|
||||
if (!nm_dbus_manager_start_service (dbus_mgr)) {
|
||||
if (!nm_dbus_manager_start_service (nm_dbus_manager_get ())) {
|
||||
nm_log_err (LOGD_CORE, "failed to start the dbus service.");
|
||||
goto done;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,15 +78,18 @@ static void nm_dbus_manager_cleanup (NMDBusManager *self, gboolean dispose);
|
|||
static void start_reconnection_timeout (NMDBusManager *self);
|
||||
static void object_destroyed (NMDBusManager *self, gpointer object);
|
||||
|
||||
NM_DEFINE_SINGLETON_DESTRUCTOR (NMDBusManager);
|
||||
NM_DEFINE_SINGLETON_WEAK_REF (NMDBusManager);
|
||||
|
||||
NMDBusManager *
|
||||
nm_dbus_manager_get (void)
|
||||
{
|
||||
static NMDBusManager *singleton_instance = NULL;
|
||||
static gsize once = 0;
|
||||
|
||||
if (g_once_init_enter (&once)) {
|
||||
singleton_instance = (NMDBusManager *) g_object_new (NM_TYPE_DBUS_MANAGER, NULL);
|
||||
g_assert (singleton_instance);
|
||||
nm_singleton_instance_weak_ref_register ();
|
||||
if (!nm_dbus_manager_init_bus (singleton_instance))
|
||||
start_reconnection_timeout (singleton_instance);
|
||||
g_once_init_leave (&once, 1);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue