summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeemu Ikonen <tpikonen@mailbox.org>2021-11-04 20:15:44 +0200
committerZeeshan Ali <zeenix@gmail.com>2021-11-07 20:37:57 +0000
commit3b5d236682772f926fa209ad9a0adef4c42d83cd (patch)
treeb19fca588bdbe688d7fab634d534c796404401bf
parent8ff08c6b54fe9dfd06d827529aa69b560192f8e6 (diff)
wifi: Wait 1 s after scan-done before refreshing location
The 'scan-done' signal is (often) emitted before 'bss-added' signals, which causes MLS queries to be made with old scan data. Wait 1 second before submitting a query, so that all signals from the scan are processed and BSS data added.
-rw-r--r--src/gclue-wifi.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/gclue-wifi.c b/src/gclue-wifi.c
index 8a319e1..6d8b7ff 100644
--- a/src/gclue-wifi.c
+++ b/src/gclue-wifi.c
@@ -491,6 +491,23 @@ on_scan_timeout (gpointer user_data)
return G_SOURCE_REMOVE;
}
+static gboolean
+on_scan_wait_done (gpointer wifi)
+{
+ GClueWifiPrivate *priv;
+
+ g_return_val_if_fail (GCLUE_IS_WIFI (wifi), G_SOURCE_REMOVE);
+ priv = GCLUE_WIFI(wifi)->priv;
+
+ if (priv->bss_list_changed) {
+ priv->bss_list_changed = FALSE;
+ g_debug ("Refreshing location…");
+ gclue_web_source_refresh (GCLUE_WEB_SOURCE (wifi));
+ }
+
+ return G_SOURCE_REMOVE;
+}
+
static void
on_scan_done (WPAInterface *object,
gboolean success,
@@ -510,11 +527,7 @@ on_scan_done (WPAInterface *object,
if (priv->interface == NULL)
return;
- if (priv->bss_list_changed) {
- priv->bss_list_changed = FALSE;
- g_debug ("Refreshing location…");
- gclue_web_source_refresh (GCLUE_WEB_SOURCE (wifi));
- }
+ g_timeout_add_seconds (1, on_scan_wait_done, wifi);
/* If there was another scan already scheduled, cancel that and
* re-schedule. Regardless of our internal book-keeping, this can happen