Merge lp:~phablet-team/network-manager/lp1480877-wifi-rm-dup-scan-signals into lp:~network-manager/network-manager/ubuntu

Proposed by Tony Espy
Status: Merged
Approved by: Mathieu Trudel-Lapierre
Approved revision: 997
Merged at revision: 998
Proposed branch: lp:~phablet-team/network-manager/lp1480877-wifi-rm-dup-scan-signals
Merge into: lp:~network-manager/network-manager/ubuntu
Diff against target: 202 lines (+121/-33)
2 files modified
debian/changelog (+11/-0)
debian/patches/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch (+110/-33)
To merge this branch: bzr merge lp:~phablet-team/network-manager/lp1480877-wifi-rm-dup-scan-signals
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre Needs Information
Manuel de la Peña (community) Approve
Review via email: mp+271575@code.launchpad.net

Description of the change

This change fixes a problem where duplicate (2-3x) AccessPoint 'LastSeen' PropertiesChanged signals are generated each time a WiFi scan completes. This can be seen by running:

dbus-monitor --system --profile "type='signal',sender='org.freedesktop.NetworkManager'"

...and waiting for a scan to occur. You'll see 2-3 PropsChanged for each AccessPoint after a scan. From then on, you'll only see changes for AccessPoint/0 until the next scan happens.

The change makes cull_scan_list the function responsible for updating an AP's last-seen property, and ensures that scan_done_cb is the only function that calls cull_scan_list. It also removes the bss_updated_cb function, as its only purpose was to update the last-seen property and schedule yet another scanlist cull.

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Have you discussed this with the upstream developers?

The suggested changes look reasonable, but there may be unforseen consequences to changing the code this way. Have you made sure that scan were still running in a reasonable fashion, even if a scan request failed, for example? It seems to me (from memory) that this would be one case where we might expect beacons to possibly schedule a new scan.

I much less intrusive change would be to simply remove the last-seen update on bss-updated -- it still makes sense to update last-seen for every scan results, otherwise it defeats its purpose... Still, there can be cases where scans fail, or when that value won't be up to date enough.

review: Needs Information
Revision history for this message
Tony Espy (awe) wrote :

My changes have no effect on whether or not scans are scheduled.

For the gory details see:

https://bugs.launchpad.net/ubuntu-rtm/+source/network-manager/+bug/1480877/comments/41

I checked, and the change that introduced DUP signals in first place was a location services fix ( see: 0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch ), which hasn't been up-streamed, so my changes aren't really directly applicable.

I've test three different phones, and a laptop running wily, and the only time bss_updated_cb is ever fired is after a scan completes. As scan_done_cb always calls cull_scan_list directly, which in turn updates all of the last-seen properties of the know AccessPoints, the removal of bss_updated_cb is basically a no-op.

The removal of the schedule_scan_list call from new_bss_cb again is also predicated on the fact that new_bss_cb only ever gets triggered when a scan happens. As it was the last function that used schedule_scanlist_cull, I removed it and the associated functions/priv member.

Revision history for this message
Manuel de la Peña (mandel) wrote :

This should not affect the location service and fixes the redundant signals.

review: Approve
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Have you made sure that this did not break the signal level change notifications, and that we can still see signal level changes in the indicator on desktop?

review: Needs Information
Revision history for this message
Tony Espy (awe) wrote :

If you mean, signal changes for the currently connected AP ( AccessPoint/0 ), then yes, I've verified that this doesn't break signal strength changes for the current AP.

These signal strength updates are handled by periodic_update_cb, which fires every six seconds when connected to an AP. This callback in turn calls a function periodic_update which reads the signal strength of the connected AP via NMPlaform and then sets the AP property, which fires a DBus signal.

That said, I've only verified this behavior directly on a phone (krillin stable #25) running the 0.9.10 version of this patch. If you want me to verify it on a wily desktop before we build the silo, I will do so...

Revision history for this message
Tony Espy (awe) wrote :

Just tested on my Thinkpad T410s running wily. It has an Intel WiFi adapter and is running iwlwifi.

Confirmed that DBus signal strength PropertiesChanged signals for AccessPoint/0 are still fired periodically when associated with an access point. Also confirmed that the indicator sees these signals and responds by changing the WiFi icon according to signal strength.

Testing with version 1.0.4-0ubuntu4~awe3 from my PPA:

https://launchpad.net/~awe/+archive/ubuntu/ppa/+packages

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-09-10 18:53:27 +0000
+++ debian/changelog 2015-09-17 22:30:05 +0000
@@ -1,3 +1,14 @@
1network-manager (1.0.4-0ubuntu4) UNRELEASED; urgency=medium
2
3 [ Tony Espy ]
4 * d/p/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch:
5 Fix duplicate 'LastSeen' PropertiesChanged signals being generated
6 after every scan. The 'Last-Seen' property is now only updated when
7 a scan finishes, and schedule_scanlist_cull is no longer triggered
8 new_bss_cb or updated_bss_cb.
9
10 -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com> Thu, 17 Sep 2015 17:03:06 -0400
11
1network-manager (1.0.4-0ubuntu3) wily; urgency=medium12network-manager (1.0.4-0ubuntu3) wily; urgency=medium
213
3 * New upstream NM release post-feature-freeze. (LP: #1493934)14 * New upstream NM release post-feature-freeze. (LP: #1493934)
415
=== modified file 'debian/patches/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch'
--- debian/patches/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch 2015-08-20 01:07:00 +0000
+++ debian/patches/0002-wifi-cull-the-scan-list-before-signalling-ScanDone-b.patch 2015-09-17 22:30:05 +0000
@@ -14,33 +14,70 @@
14 src/devices/wifi/nm-device-wifi.c | 35 +++++++++++++++++++++++++++++------14 src/devices/wifi/nm-device-wifi.c | 35 +++++++++++++++++++++++++++++------
15 1 file changed, 29 insertions(+), 6 deletions(-)15 1 file changed, 29 insertions(+), 6 deletions(-)
1616
17Index: b/src/devices/wifi/nm-device-wifi.c17Index: network-manager-1.0.4/src/devices/wifi/nm-device-wifi.c
18===================================================================18===================================================================
19--- a/src/devices/wifi/nm-device-wifi.c19--- network-manager-1.0.4.orig/src/devices/wifi/nm-device-wifi.c
20+++ b/src/devices/wifi/nm-device-wifi.c20+++ network-manager-1.0.4/src/devices/wifi/nm-device-wifi.c
21@@ -177,6 +177,10 @@ static void supplicant_iface_notify_scan21@@ -123,7 +123,6 @@ struct _NMDeviceWifiPrivate {
22 gint32 scheduled_scan_time;
23 guint8 scan_interval; /* seconds */
24 guint pending_scan_id;
25- guint scanlist_cull_id;
26 gboolean requested_scan;
27
28 NMSupplicantManager *sup_mgr;
29@@ -160,11 +159,6 @@ static void supplicant_iface_new_bss_cb
30 GVariant *properties,
31 NMDeviceWifi * self);
32
33-static void supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
34- const char *object_path,
35- GHashTable *properties,
36- NMDeviceWifi *self);
37-
38 static void supplicant_iface_bss_removed_cb (NMSupplicantInterface *iface,
39 const char *object_path,
40 NMDeviceWifi *self);
41@@ -177,7 +171,7 @@ static void supplicant_iface_notify_scan
22 GParamSpec * pspec,42 GParamSpec * pspec,
23 NMDeviceWifi * self);43 NMDeviceWifi * self);
24 44
25+static void remove_outstanding_scanlist_cull(NMDeviceWifi *self);45-static void schedule_scanlist_cull (NMDeviceWifi *self);
26+
27+static gboolean cull_scan_list(NMDeviceWifi *self);46+static gboolean cull_scan_list(NMDeviceWifi *self);
28+
29 static void schedule_scanlist_cull (NMDeviceWifi *self);
30 47
31 static gboolean request_wireless_scan (gpointer user_data);48 static gboolean request_wireless_scan (gpointer user_data);
32@@ -1607,14 +1611,22 @@ supplicant_iface_scan_done_cb (NMSupplic49
50@@ -252,10 +246,6 @@ supplicant_interface_acquire (NMDeviceWi
51 G_CALLBACK (supplicant_iface_new_bss_cb),
52 self);
53 g_signal_connect (priv->sup_iface,
54- NM_SUPPLICANT_INTERFACE_BSS_UPDATED,
55- G_CALLBACK (supplicant_iface_bss_updated_cb),
56- self);
57- g_signal_connect (priv->sup_iface,
58 NM_SUPPLICANT_INTERFACE_BSS_REMOVED,
59 G_CALLBACK (supplicant_iface_bss_removed_cb),
60 self);
61@@ -287,11 +277,6 @@ supplicant_interface_release (NMDeviceWi
62 _LOGD (LOGD_WIFI_SCAN, "reset scanning interval to %d seconds",
63 priv->scan_interval);
64
65- if (priv->scanlist_cull_id) {
66- g_source_remove (priv->scanlist_cull_id);
67- priv->scanlist_cull_id = 0;
68- }
69-
70 if (priv->sup_iface) {
71 remove_supplicant_interface_error_handler (self);
72
73@@ -1607,14 +1592,17 @@ supplicant_iface_scan_done_cb (NMSupplic
33 74
34 _LOGD (LOGD_WIFI_SCAN, "scan %s", success ? "successful" : "failed");75 _LOGD (LOGD_WIFI_SCAN, "scan %s", success ? "successful" : "failed");
35 76
36- g_signal_emit (self, signals[SCAN_DONE], 0, NULL);77- g_signal_emit (self, signals[SCAN_DONE], 0, NULL);
37-78-
38- schedule_scan (self, success);79- schedule_scan (self, success);
39+ /* Make sure that scheduled and not yet run scanlist cull80-
40+ * requests are aborted.
41+ */
42+ remove_outstanding_scanlist_cull (self);
43
44 /* Ensure that old APs get removed, which otherwise only81 /* Ensure that old APs get removed, which otherwise only
45 * happens when there are new BSSes.82 * happens when there are new BSSes.
46 */83 */
@@ -56,7 +93,16 @@
56 93
57 if (priv->requested_scan) {94 if (priv->requested_scan) {
58 priv->requested_scan = FALSE;95 priv->requested_scan = FALSE;
59@@ -1786,8 +1798,10 @@ cull_scan_list (NMDeviceWifi *self)96@@ -1761,8 +1749,6 @@ cull_scan_list (NMDeviceWifi *self)
97 GSList *elt;
98 guint32 removed = 0, total = 0;
99
100- priv->scanlist_cull_id = 0;
101-
102 _LOGD (LOGD_WIFI_SCAN, "checking scan list for outdated APs");
103
104 /* Walk the access point list and remove any access points older than
105@@ -1786,8 +1772,10 @@ cull_scan_list (NMDeviceWifi *self)
60 * supplicant in the last scan.106 * supplicant in the last scan.
61 */107 */
62 if ( nm_ap_get_supplicant_path (ap)108 if ( nm_ap_get_supplicant_path (ap)
@@ -68,27 +114,58 @@
68 114
69 last_seen = nm_ap_get_last_seen (ap);115 last_seen = nm_ap_get_last_seen (ap);
70 if (!last_seen || last_seen + prune_interval_s < boottime_now)116 if (!last_seen || last_seen + prune_interval_s < boottime_now)
71@@ -1824,13 +1838,22 @@ cull_scan_list (NMDeviceWifi *self)117@@ -1824,17 +1812,6 @@ cull_scan_list (NMDeviceWifi *self)
72 }118 }
73 119
74 static void120 static void
75-schedule_scanlist_cull (NMDeviceWifi *self)121-schedule_scanlist_cull (NMDeviceWifi *self)
76+remove_outstanding_scanlist_cull (NMDeviceWifi *self)122-{
77 {123- NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
78 NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);124-
79 125- /* Cull the scan list after the last request for it has come in */
80 /* Cull the scan list after the last request for it has come in */126- if (priv->scanlist_cull_id)
81 if (priv->scanlist_cull_id)127- g_source_remove (priv->scanlist_cull_id);
82 g_source_remove (priv->scanlist_cull_id);128- priv->scanlist_cull_id = g_timeout_add_seconds (4, (GSourceFunc) cull_scan_list, self);
83+}129-}
84+130-
85+static void131-static void
86+schedule_scanlist_cull (NMDeviceWifi *self)132 supplicant_iface_new_bss_cb (NMSupplicantInterface *iface,
87+{133 const char *object_path,
88+ NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);134 GVariant *properties,
89+135@@ -1863,36 +1840,6 @@ supplicant_iface_new_bss_cb (NMSupplican
90+ remove_outstanding_scanlist_cull(self);136 g_object_unref (ap);
91+137 } else
92 priv->scanlist_cull_id = g_timeout_add_seconds (4, (GSourceFunc) cull_scan_list, self);138 _LOGW (LOGD_WIFI_SCAN, "invalid AP properties received");
139-
140- /* Remove outdated access points */
141- schedule_scanlist_cull (self);
142-}
143-
144-static void
145-supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
146- const char *object_path,
147- GHashTable *properties,
148- NMDeviceWifi *self)
149-{
150- NMDeviceState state;
151- NMAccessPoint *ap;
152-
153- g_return_if_fail (self != NULL);
154- g_return_if_fail (object_path != NULL);
155- g_return_if_fail (properties != NULL);
156-
157- /* Ignore new APs when unavailable or unamnaged */
158- state = nm_device_get_state (NM_DEVICE (self));
159- if (state <= NM_DEVICE_STATE_UNAVAILABLE)
160- return;
161-
162- /* Update the AP's last-seen property */
163- ap = get_ap_by_supplicant_path (self, object_path);
164- if (ap)
165- nm_ap_update_last_seen (ap);
166-
167- /* Remove outdated access points */
168- schedule_scanlist_cull (self);
93 }169 }
94 170
171 static void

Subscribers

People subscribed via source and target branches