From 7f79b59330290fc406c4d9bf76d3b5216434cde3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 2 Jun 2017 16:09:55 +0200 Subject: [PATCH] device: move carrier_changed_notify() notification to nm_device_set_carrier() Note that: - carrier_changed_notify() has only one implementation: NMDeviceEthernet to call get_link_speed() when carrier comes back. - currently, calling carrier_changed_notify() with carrier=FALSE has no effect, because NMDeviceEthernet only acts on carrier=TRUE. - when carrier appears, nm_device_set_carrier() will call carrier_changed() right away. We only call carrier_changed() with carrier=TRUE only at one place. The change merley moves carrier_changed_notify() out of the function. Apart from that it has no effect. - when carrier disappears, previoulsy we would delay action for 4 seconds. Hence, we would delay carrier_changed_notify() as well -- although it has no effect. The last point is at least ugly. Fix it by moving carrier_changed_notify() to nm_device_set_carrier(). --- src/devices/nm-device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e11b7158fb..c006d9aa5a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2183,8 +2183,6 @@ carrier_changed (NMDevice *self, gboolean carrier) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - NM_DEVICE_GET_CLASS (self)->carrier_changed_notify (self, carrier); - if (priv->state <= NM_DEVICE_STATE_UNMANAGED) return; @@ -2288,6 +2286,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) if (priv->carrier) { _LOGI (LOGD_DEVICE, "link connected"); carrier_disconnected_action_cancel (self); + NM_DEVICE_GET_CLASS (self)->carrier_changed_notify (self, carrier); carrier_changed (self, TRUE); if (priv->carrier_wait_id) { @@ -2297,6 +2296,7 @@ nm_device_set_carrier (NMDevice *self, gboolean carrier) } else { if (priv->carrier_wait_id) nm_device_add_pending_action (self, NM_PENDING_ACTION_CARRIER_WAIT, FALSE); + NM_DEVICE_GET_CLASS (self)->carrier_changed_notify (self, carrier); if ( state <= NM_DEVICE_STATE_DISCONNECTED && !priv->queued_act_request) { _LOGD (LOGD_DEVICE, "link disconnected");