summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2014-10-06 17:17:54 -0500
committerDan Williams <dcbw@redhat.com>2014-12-11 10:07:42 -0600
commitbb030412ebf8fe28ea01d285700b496f75c31305 (patch)
tree9959c7000dc485e244224e6cbffaa61f2eab6d51
parent18613d30bf928b3ab18279dcaa93537571274ced (diff)
downloadNetworkManager-bb030412ebf8fe28ea01d285700b496f75c31305.tar.gz
core: rearrange some VLAN code and clean up dispose()
Move parent-related stuff before its callers and clean up dispose so that we no longer need priv->disposed.
-rw-r--r--src/devices/nm-device-vlan.c90
1 files changed, 38 insertions, 52 deletions
diff --git a/src/devices/nm-device-vlan.c b/src/devices/nm-device-vlan.c
index d291191670..2b5614c321 100644
--- a/src/devices/nm-device-vlan.c
+++ b/src/devices/nm-device-vlan.c
@@ -51,11 +51,8 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE)
#define NM_DEVICE_VLAN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_VLAN, NMDeviceVlanPrivate))
typedef struct {
- gboolean disposed;
-
NMDevice *parent;
guint parent_state_id;
-
int vlan_id;
} NMDeviceVlanPrivate;
@@ -67,11 +64,46 @@ enum {
LAST_PROP
};
-static void nm_device_vlan_set_parent (NMDeviceVlan *device, NMDevice *parent);
-
/******************************************************************/
static void
+parent_state_changed (NMDevice *parent,
+ NMDeviceState new_state,
+ NMDeviceState old_state,
+ NMDeviceStateReason reason,
+ gpointer user_data)
+{
+ NMDeviceVlan *self = NM_DEVICE_VLAN (user_data);
+
+ /* We'll react to our own carrier state notifications. Ignore the parent's. */
+ if (reason == NM_DEVICE_STATE_REASON_CARRIER)
+ return;
+
+ nm_device_set_unmanaged (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent), reason);
+}
+
+static void
+nm_device_vlan_set_parent (NMDeviceVlan *device, NMDevice *parent)
+{
+ NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
+
+ if (priv->parent_state_id) {
+ g_signal_handler_disconnect (priv->parent, priv->parent_state_id);
+ priv->parent_state_id = 0;
+ }
+ g_clear_object (&priv->parent);
+
+ if (parent) {
+ priv->parent = g_object_ref (parent);
+ priv->parent_state_id = g_signal_connect (priv->parent,
+ "state-changed",
+ G_CALLBACK (parent_state_changed),
+ device);
+ }
+ g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT);
+}
+
+static void
setup (NMDevice *device, NMPlatformLink *plink)
{
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
@@ -339,43 +371,6 @@ complete_connection (NMDevice *device,
}
static void
-parent_state_changed (NMDevice *parent,
- NMDeviceState new_state,
- NMDeviceState old_state,
- NMDeviceStateReason reason,
- gpointer user_data)
-{
- NMDeviceVlan *self = NM_DEVICE_VLAN (user_data);
-
- /* We'll react to our own carrier state notifications. Ignore the parent's. */
- if (reason == NM_DEVICE_STATE_REASON_CARRIER)
- return;
-
- nm_device_set_unmanaged (NM_DEVICE (self), NM_UNMANAGED_PARENT, !nm_device_get_managed (parent), reason);
-}
-
-static void
-nm_device_vlan_set_parent (NMDeviceVlan *device, NMDevice *parent)
-{
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (device);
-
- if (priv->parent_state_id) {
- g_signal_handler_disconnect (priv->parent, priv->parent_state_id);
- priv->parent_state_id = 0;
- }
- g_clear_object (&priv->parent);
-
- if (parent) {
- priv->parent = g_object_ref (parent);
- priv->parent_state_id = g_signal_connect (priv->parent,
- "state-changed",
- G_CALLBACK (parent_state_changed),
- device);
- }
- g_object_notify (G_OBJECT (device), NM_DEVICE_VLAN_PARENT);
-}
-
-static void
update_connection (NMDevice *device, NMConnection *connection)
{
NMDeviceVlan *self = NM_DEVICE_VLAN (device);
@@ -546,16 +541,7 @@ set_property (GObject *object, guint prop_id,
static void
dispose (GObject *object)
{
- NMDeviceVlan *self = NM_DEVICE_VLAN (object);
- NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
-
- if (priv->disposed) {
- G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
- return;
- }
- priv->disposed = TRUE;
-
- nm_device_vlan_set_parent (self, NULL);
+ nm_device_vlan_set_parent (NM_DEVICE_VLAN (object), NULL);
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
}