From 788583d9fd35f9a83c932c5fa6ca059e19fcd7c6 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 Jul 2016 09:30:46 +0200 Subject: [PATCH] wifi: fix missing pending-action-remove for "scan" [1467730406.7343] device (wlp3s0): add_pending_action (2): scan already pending file devices/nm-device.c: line 10443 (nm_device_add_pending_action): should not be reached Fixes: eed8fd2e43d244caa856d9993e750ff19ba62fd7 --- src/devices/wifi/nm-device-wifi.c | 33 ++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index 37ec4a612..3c512b1a5 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -256,6 +256,24 @@ supplicant_interface_acquire (NMDeviceWifi *self) return TRUE; } +static void +_requested_scan_set (NMDeviceWifi *self, gboolean value) +{ + NMDeviceWifiPrivate *priv; + + value = !!value; + + priv = NM_DEVICE_WIFI_GET_PRIVATE (self); + if (priv->requested_scan == value) + return; + + priv->requested_scan = value; + if (value) + nm_device_add_pending_action ((NMDevice *) self, "scan", TRUE); + else + nm_device_remove_pending_action ((NMDevice *) self, "scan", TRUE); +} + static void supplicant_interface_release (NMDeviceWifi *self) { @@ -265,10 +283,7 @@ supplicant_interface_release (NMDeviceWifi *self) priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - if (priv->requested_scan) { - priv->requested_scan = FALSE; - nm_device_remove_pending_action (NM_DEVICE (self), "scan", TRUE); - } + _requested_scan_set (self, FALSE); nm_clear_g_source (&priv->pending_scan_id); @@ -1403,8 +1418,7 @@ request_wireless_scan (NMDeviceWifi *self, GVariant *scan_options) if (nm_supplicant_interface_request_scan (priv->sup_iface, ssids)) { /* success */ backoff = TRUE; - priv->requested_scan = TRUE; - nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE); + _requested_scan_set (self, TRUE); } if (ssids) @@ -1486,10 +1500,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface, priv->last_scan = nm_utils_get_monotonic_timestamp_s (); schedule_scan (self, success); - if (priv->requested_scan) { - priv->requested_scan = FALSE; - nm_device_remove_pending_action (NM_DEVICE (self), "scan", TRUE); - } + _requested_scan_set (self, FALSE); } /**************************************************************************** @@ -2024,7 +2035,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface, _LOGI (LOGD_DEVICE | LOGD_WIFI, "supplicant interface keeps failing, giving up"); break; case NM_SUPPLICANT_INTERFACE_STATE_INACTIVE: - priv->requested_scan = FALSE; + _requested_scan_set (self, FALSE); nm_clear_g_source (&priv->pending_scan_id); request_wireless_scan (self, NULL); break;