From 86fd0402d964de520077f8340e7d9eb93fd532bf Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 27 Jan 2018 15:56:55 +0100 Subject: [PATCH] ifcfg-rh: minor cleanup for _dbus_setup() In _dbus_setup(), call _dbus_clear(). It feels more correct to do that. Although, technically, we never even call _dbus_setup() if there is anything to clear. Also, minor refactoring of config_changed_cb(). It's not entirely clear whether we need that code, or how to handle D-Bus disconnecting, if at all. --- .../plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c index aa1e3c001b..437861bf13 100644 --- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c +++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-plugin.c @@ -917,7 +917,7 @@ _dbus_setup (SettingsPluginIfcfg *self) gs_free char *address = NULL; gs_free_error GError *error = NULL; - g_return_if_fail (!priv->dbus.connection); + _dbus_clear (self); address = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, &error); if (address == NULL) { @@ -943,17 +943,22 @@ config_changed_cb (NMConfig *config, NMConfigData *old_data, SettingsPluginIfcfg *self) { + SettingsPluginIfcfgPrivate *priv; + /* If the dbus connection for some reason is borked the D-Bus service * won't be offered. * * On SIGHUP and SIGUSR1 try to re-connect to D-Bus. So in the unlikely * event that the D-Bus conneciton is broken, that allows for recovery * without need for restarting NetworkManager. */ - if (NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP - | NM_CONFIG_CHANGE_CAUSE_SIGUSR1)) { - if (!SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self)->dbus.connection) - _dbus_setup (self); - } + if (!NM_FLAGS_ANY (changes, NM_CONFIG_CHANGE_CAUSE_SIGHUP + | NM_CONFIG_CHANGE_CAUSE_SIGUSR1)) + return; + + priv = SETTINGS_PLUGIN_IFCFG_GET_PRIVATE (self); + if ( !priv->dbus.connection + && !priv->dbus.cancellable) + _dbus_setup (self); } /*****************************************************************************/