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().
This commit is contained in:
Thomas Haller 2017-06-02 16:09:55 +02:00
parent 1d35fd0103
commit 7f79b59330

View file

@ -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");