From 61e4b5a23013aaa60ec15e98bf38d3a0920eb54a Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Sat, 10 Oct 2020 17:37:34 +0200 Subject: [PATCH] iwd: Don't auto-scan while waiting for secrets IWD's Station.State property remains at "connect" or "disconnected" while IWD is waiting for secrets for a new conncetion, so if we want to scan only when NM might be in auto-connect (which was the goal) we need to also look at NMDevice's state. We want to scan whenever wifi is disconnected and there's no active connection request, which is the same as saying whever priv->current_ap is unset so for simplicity look at priv->current_ap. Also in schedule_periodic_scan() don't check whether Station.State is "disconnected" because priv->can_scan is equivalent to Station.State being one of ("disconnected", "connected"). --- src/devices/wifi/nm-device-iwd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/devices/wifi/nm-device-iwd.c b/src/devices/wifi/nm-device-iwd.c index d33d6cdba5..8ca35ae78a 100644 --- a/src/devices/wifi/nm-device-iwd.c +++ b/src/devices/wifi/nm-device-iwd.c @@ -162,6 +162,7 @@ set_current_ap(NMDeviceIwd *self, NMWifiAP *new_ap, gboolean recheck_available_c _notify(self, PROP_ACTIVE_ACCESS_POINT); _notify(self, PROP_MODE); + schedule_periodic_scan(self, TRUE); } static void @@ -1958,16 +1959,8 @@ static void schedule_periodic_scan(NMDeviceIwd *self, gboolean initial_scan) { NMDeviceIwdPrivate *priv = NM_DEVICE_IWD_GET_PRIVATE(self); - GVariant * value; - gboolean disconnected = TRUE; guint interval; - if (priv->can_scan) { - value = g_dbus_proxy_get_cached_property(priv->dbus_station_proxy, "State"); - disconnected = nm_streq0(get_variant_state(value), "disconnected"); - g_variant_unref(value); - } - /* Start scan immediately after a disconnect, mode change or * device UP, otherwise wait 10 seconds. When connected, update * AP list mainly on UI requests. @@ -1979,7 +1972,7 @@ schedule_periodic_scan(NMDeviceIwd *self, gboolean initial_scan) * exit autoconnect and interrupt the ongoing scan, meaning that * we still want a new scan ASAP. */ - if (!priv->can_scan || !disconnected || priv->scan_requested || priv->scanning) + if (!priv->can_scan || priv->scan_requested || priv->scanning || priv->current_ap) interval = -1; else if (initial_scan) interval = 0;