Commit 79f6d4ad authored by Thomas Haller's avatar Thomas Haller

wireguard: refactor cleanup of NMDeviceWireGuard on disconnect/dispose

parent 9d88f0d7
......@@ -1405,21 +1405,25 @@ get_configured_mtu (NMDevice *device, NMDeviceMtuSource *out_source)
out_source);
}
static void
_device_cleanup (NMDeviceWireGuard *self)
{
NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (self);
_peers_remove_all (priv);
_secrets_cancel (self);
}
static void
device_state_changed (NMDevice *device,
NMDeviceState new_state,
NMDeviceState old_state,
NMDeviceStateReason reason)
{
NMDeviceWireGuardPrivate *priv;
if (new_state <= NM_DEVICE_STATE_ACTIVATED)
return;
priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (device);
_peers_remove_all (priv);
_secrets_cancel (NM_DEVICE_WIREGUARD (device));
_device_cleanup (NM_DEVICE_WIREGUARD (device));
}
/*****************************************************************************/
......@@ -1567,11 +1571,8 @@ static void
dispose (GObject *object)
{
NMDeviceWireGuard *self = NM_DEVICE_WIREGUARD (object);
NMDeviceWireGuardPrivate *priv = NM_DEVICE_WIREGUARD_GET_PRIVATE (self);
_secrets_cancel (self);
_peers_remove_all (priv);
_device_cleanup (self);
G_OBJECT_CLASS (nm_device_wireguard_parent_class)->dispose (object);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment