diff options
author | Dan Williams <dcbw@redhat.com> | 2015-10-22 13:42:42 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2016-01-25 12:40:08 -0600 |
commit | 7878e91b773d179764c2a2934e1949dd4e4fa9c5 (patch) | |
tree | adf1024edb9be7458c780cdef914de816f6d3e4d /src | |
parent | 859099f3534f090fb88de497474164c86dc610ea (diff) |
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
(cherry picked from commit d9c6b9f3dd8463dc636115c20e2d84a1a07b4fbe)
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/nm-device.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 6fa64b19dd..d47837d376 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2539,13 +2539,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; } |