summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2015-10-22 13:42:42 -0500
committerDan Williams <dcbw@redhat.com>2015-11-02 14:02:17 -0600
commite794a3f39a48eeb32dcbd8db2f558c0d53c5ee77 (patch)
treefe58d3a7420c2677b9b06c70c4b00772c331a805
parent9eda6e0f7c76e2a397f49b436205e448685b839b (diff)
downloadNetworkManager-e794a3f39a48eeb32dcbd8db2f558c0d53c5ee77.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 4b6d2d45fc..e10b4b2ccb 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2766,13 +2766,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;
}