From c59eb16817f266c4fdc69e42401778ea29546a01 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 4 Mar 2009 12:58:52 -0500 Subject: [PATCH] wifi: remove user-created Ad-Hoc APs from the scan list when no longer used (bgo #569241) The first fix didn't cover creating a new adhoc network while already joined to an existing adhoc network; thus clearing the 'fake' flag wouldn't necessarily drop the old adhoc network from the scan list, because NM doesn't scan in adhoc mode, and thus the scan list culling function wouldn't run. Even if the AP being removed isn't adhoc, it was never found from a scan anyway (if it had, the fake flag would have been reset) and thus we don't care about it anymore. --- src/nm-device-wifi.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/nm-device-wifi.c b/src/nm-device-wifi.c index 9fe51a3a0c..38c49c4290 100644 --- a/src/nm-device-wifi.c +++ b/src/nm-device-wifi.c @@ -1044,26 +1044,27 @@ real_deactivate_quickly (NMDevice *dev) { NMDeviceWifi *self = NM_DEVICE_WIFI (dev); NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self); - NMAccessPoint *orig_ap; + NMAccessPoint *orig_ap = nm_device_wifi_get_activation_ap (self); cleanup_association_attempt (self, TRUE); - /* If the AP is 'fake', i.e. it wasn't actually found from - * a scan but the user tried to connect to it manually (maybe it - * was non-broadcasting or something) clear the 'fake' flag here, - * becuase 'fake' APs should only live for as long as we're - * connected to them. Fixes a bug where user-created Ad-Hoc APs - * are never removed from the scan list, because scanning is - * disabled while in Ad-Hoc mode (for stability), and thus the - * AP culling never happens. (bgo #569241) - */ - orig_ap = nm_device_wifi_get_activation_ap (self); - if (orig_ap && nm_ap_get_fake (orig_ap)) - nm_ap_set_fake (orig_ap, FALSE); - set_current_ap (self, NULL); priv->rate = 0; + /* If the AP is 'fake', i.e. it wasn't actually found from + * a scan but the user tried to connect to it manually (maybe it + * was non-broadcasting or something) get rid of it, because 'fake' + * APs should only live for as long as we're connected to them. Fixes + * a bug where user-created Ad-Hoc APs are never removed from the scan + * list, because scanning is disabled while in Ad-Hoc mode (for stability), + * and thus the AP culling never happens. (bgo #569241) + */ + if (orig_ap && nm_ap_get_fake (orig_ap)) { + access_point_removed (self, orig_ap); + priv->ap_list = g_slist_remove (priv->ap_list, orig_ap); + g_object_unref (orig_ap); + } + /* Clean up stuff, don't leave the card associated */ nm_device_wifi_set_ssid (self, NULL); nm_device_wifi_disable_encryption (self); @@ -3175,6 +3176,8 @@ activation_success_handler (NMDevice *dev) nm_ap_set_address (ap, &bssid); if (!nm_ap_get_freq (ap)) nm_ap_set_freq (ap, nm_device_wifi_get_frequency (self)); + if (!nm_ap_get_max_bitrate (ap) && nm_ap_get_user_created (ap)) + nm_ap_set_max_bitrate (ap, nm_device_wifi_get_bitrate (self)); tmp_ap = get_active_ap (self, ap, TRUE); if (tmp_ap) {