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.
This commit is contained in:
Thomas Haller 2018-01-27 15:56:55 +01:00
parent 5b6612dea1
commit 86fd0402d9

View file

@ -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);
}
/*****************************************************************************/