[PATCH] Call cull_scan_list even if there is no access point reported.



The attached patch can help with aging of results when moving into to a place 
with no access points (yeah, we can still find some).

Comments are welcome.

PS: although cull_scan_list() is called not that often and ap_list is not that 
big, we could do a better code there. First  g_slist_append() is O(n) and we 
really don't care about order, so g_slist_prepend() should be used (also true 
in other parts of NetworkManager as well). Also, removing from the list as we 
walk it is not that hard, just update elt = elt->next before doing any real 
work. I can provide patches if you like the idea.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems / Canonical Contractor
--------------------------------------
MSN: barbieri gmail com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202
From f0413d9b2c8ab7bf1bb7f32c8143a3d650e49f6b Mon Sep 17 00:00:00 2001
From: Gustavo Sverzut Barbieri <barbieri profusion mobi>
Date: Mon, 27 Apr 2009 14:04:12 -0300
Subject: [PATCH] Call cull_scan_list even if there is no access point reported.

cull_scan_list() is being called only from
supplicant_iface_scanned_ap_cb, which is reported by wpa
supplicant. If there is no access point it will not run and stale
access point will live.

Since this will increase calls to cull_scan_list(), added
last_cull_time in order to prevent calling this function in the same
second, since it would be useless. This is a cheap way, maybe a better
solution would be to g_idle_add() and remember the source id, handle
it at finalize and just add new if the old already executed and zeroed
the source id.
---
 src/nm-device-wifi.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c
index 63c2c9d..c6d47fd 100644
--- a/src/nm-device-wifi.c
+++ b/src/nm-device-wifi.c
@@ -56,6 +56,8 @@ static gboolean impl_device_get_access_points (NMDeviceWifi *device,
                                                GPtrArray **aps,
                                                GError **err);
 
+static void cull_scan_list (NMDeviceWifi *self);
+
 #include "nm-device-wifi-glue.h"
 
 
@@ -156,6 +158,7 @@ struct _NMDeviceWifiPrivate
 	
 	gboolean			scanning;
 	glong			scheduled_scan_time;
+	glong			last_cull_time; /* seconds */
 	guint8			scan_interval; /* seconds */
 	guint               pending_scan_id;
 
@@ -966,6 +969,9 @@ nm_device_wifi_periodic_update (gpointer data)
 	periodic_update (self);
 
 out:
+	/* Remove outdated access points */
+	cull_scan_list (self);
+
 	return TRUE;
 }
 
@@ -2030,6 +2036,10 @@ cull_scan_list (NMDeviceWifi *self)
 
 	g_get_current_time (&cur_time);
 
+	if (priv->last_cull_time >= cur_time.tv_sec)
+		return;
+	priv->last_cull_time = cur_time.tv_sec;
+
 	req = nm_device_get_act_request (NM_DEVICE (self));
 	if (req)
 		cur_ap_path = nm_act_request_get_specific_object (req);
-- 
1.6.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]