diff options
author | Thomas Haller <thaller@redhat.com> | 2014-06-12 14:20:14 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-06-16 19:18:57 +0200 |
commit | afecbf1f661a775f6164c469f392f549483ffe52 (patch) | |
tree | a69689cf1f358fdeffe5384239a2d05b1c17a6e3 | |
parent | 851be22146828fdb6aa18c83ff0d08fa64310522 (diff) | |
download | NetworkManager-afecbf1f661a775f6164c469f392f549483ffe52.tar.gz |
device: refactor by combining dispatcher callback functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | src/devices/nm-device.c | 62 |
1 files changed, 33 insertions, 29 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6c04187d76..4d70f24595 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -216,8 +216,11 @@ typedef struct { guint act_source6_id; gpointer act_source6_func; guint recheck_assume_id; - guint dispatcher_id; - NMDeviceStateReason dispatcher_pre_down_reason; + struct { + guint call_id; + NMDeviceState post_state; + NMDeviceStateReason post_state_reason; + } dispatcher; /* Link stuff */ guint link_connected_id; @@ -5273,39 +5276,51 @@ dispatcher_cleanup (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - if (priv->dispatcher_id) { - nm_dispatcher_call_cancel (priv->dispatcher_id); - priv->dispatcher_id = 0; + if (priv->dispatcher.call_id) { + nm_dispatcher_call_cancel (priv->dispatcher.call_id); + priv->dispatcher.call_id = 0; + priv->dispatcher.post_state = NM_DEVICE_STATE_UNKNOWN; + priv->dispatcher.post_state_reason = NM_DEVICE_STATE_REASON_NONE; } } static void -ip_check_pre_up_done (guint call_id, gpointer user_data) +dispatcher_complete_proceed_state (guint call_id, gpointer user_data) { NMDevice *self = NM_DEVICE (user_data); NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - g_return_if_fail (call_id == priv->dispatcher_id); + g_return_if_fail (call_id == priv->dispatcher.call_id); - priv->dispatcher_id = 0; - nm_device_queue_state (self, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE); + priv->dispatcher.call_id = 0; + nm_device_queue_state (self, priv->dispatcher.post_state, + priv->dispatcher.post_state_reason); + priv->dispatcher.post_state = NM_DEVICE_STATE_UNKNOWN; + priv->dispatcher.post_state_reason = NM_DEVICE_STATE_REASON_NONE; } +/****************************************************************/ + static void ip_check_pre_up (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - g_warn_if_fail (priv->dispatcher_id == 0); + if (priv->dispatcher.call_id != 0) { + g_warn_if_reached (); + dispatcher_cleanup (self); + } + priv->dispatcher.post_state = NM_DEVICE_STATE_SECONDARIES; + priv->dispatcher.post_state_reason = NM_DEVICE_STATE_REASON_NONE; if (!nm_dispatcher_call (DISPATCHER_ACTION_PRE_UP, nm_device_get_connection (self), self, - ip_check_pre_up_done, + dispatcher_complete_proceed_state, self, - &priv->dispatcher_id)) { + &priv->dispatcher.call_id)) { /* Just proceed on errors */ - ip_check_pre_up_done (0, self); + dispatcher_complete_proceed_state (0, self); } } @@ -6537,18 +6552,6 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason) /***********************************************************/ -static void -dispatcher_pre_down_done (guint call_id, gpointer user_data) -{ - NMDevice *self = NM_DEVICE (user_data); - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - - g_return_if_fail (call_id == priv->dispatcher_id); - - priv->dispatcher_id = 0; - nm_device_queue_state (self, NM_DEVICE_STATE_DISCONNECTED, priv->dispatcher_pre_down_reason); -} - static gboolean ip_config_valid (NMDeviceState state) { @@ -6714,15 +6717,16 @@ _set_state_full (NMDevice *device, nm_act_request_get_connection (req), device); } else { - priv->dispatcher_pre_down_reason = reason; + priv->dispatcher.post_state = NM_DEVICE_STATE_DISCONNECTED; + priv->dispatcher.post_state_reason = reason; if (!nm_dispatcher_call (DISPATCHER_ACTION_PRE_DOWN, nm_act_request_get_connection (req), device, - dispatcher_pre_down_done, + dispatcher_complete_proceed_state, device, - &priv->dispatcher_id)) { + &priv->dispatcher.call_id)) { /* Just proceed on errors */ - dispatcher_pre_down_done (0, device); + dispatcher_complete_proceed_state (0, device); } } break; |