summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-10-22 13:42:42 -0500
committerDan Williams <dcbw@redhat.com>2015-12-09 13:43:54 -0600
commit9db4d31bb2c1a62a182b3a705d5d7af4ecdfa5f7 (patch)
tree8fb913187b5c41c04cb3ffc7e9801f9448da11d1
parent65c3bc57655d160be355f65b392a35b451874193 (diff)
downloadNetworkManager-9db4d31bb2c1a62a182b3a705d5d7af4ecdfa5f7.tar.gz
core: only run availability recheck transition if required
Device subclasses can call nm_device_recheck_available() at any time, and the function would change the device's state to UNKNOWN in cases where the device was available already. For WWAN devices, availability is rechecked every time the modem state changes, resulting in: NetworkManager[28919]: <info> (ttyUSB4): modem state changed, 'disabled' --> 'enabling' (reason: user-requested) NetworkManager[28919]: <debug> [1445538582.116727] [devices/nm-device.c:2769] recheck_available(): [0x23bd710] (ttyUSB4): device is available, will transition to unknown NetworkManager[28919]: <info> (ttyUSB4): modem state changed, 'enabling' --> 'searching' (reason: user-requested) NetworkManager[28919]: <debug> [1445538582.776317] [devices/nm-device.c:2769] recheck_available(): [0x23bd710] (ttyUSB4): device is available, will transition to unknown
-rw-r--r--src/devices/nm-device.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index bb39ca5546..dfc10a52a0 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2544,13 +2544,17 @@ recheck_available (gpointer user_data)
new_state = NM_DEVICE_STATE_UNAVAILABLE;
nm_device_queue_state (self, new_state, priv->recheck_available.unavailable_reason);
}
- _LOGD (LOGD_DEVICE, "device is %savailable, %s %s",
- now_available ? "" : "not ",
- new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to",
- state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state));
- priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE;
- priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE;
+ if (new_state > NM_DEVICE_STATE_UNKNOWN) {
+ _LOGD (LOGD_DEVICE, "device is %savailable, %s %s",
+ now_available ? "" : "not ",
+ new_state == NM_DEVICE_STATE_UNAVAILABLE ? "no change required for" : "will transition to",
+ state_to_string (new_state == NM_DEVICE_STATE_UNAVAILABLE ? state : new_state));
+
+ priv->recheck_available.available_reason = NM_DEVICE_STATE_REASON_NONE;
+ priv->recheck_available.unavailable_reason = NM_DEVICE_STATE_REASON_NONE;
+ }
+
return G_SOURCE_REMOVE;
}