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").
This commit is contained in:
Andrew Zaborowski 2020-10-10 17:37:34 +02:00 committed by Thomas Haller
parent 4f83960ff5
commit 61e4b5a230
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

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