NetworkManager r3365 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3365 - in trunk: . src
- Date: Fri, 29 Feb 2008 16:33:59 +0000 (GMT)
Author: dcbw
Date: Fri Feb 29 16:33:59 2008
New Revision: 3365
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3365&view=rev
Log:
2008-02-29 Dan Williams <dcbw redhat com>
* src/nm-device-802-11-wireless.c
src/nm-device-802-11-wireless.h
- (nm_device_802_11_wireless_reset_scan_interval): remove, unused
elsewhere; fold into the sole user in nm-device-802-11-wireless.c
- (device_cleanup): reset the scan interval lower when the device
deactivates
- (can_scan): base decision mostly off device state, not supplicant
interface state since the supplicant interface state isn't a
great indicator of whether the device is active or not
- (request_wireless_scan): clean up; schedule the next scan here
- (schedule_scan): only back the scan interval off if a new scan
actually gets scheduled; and make scan intervals tighter when the
device is disconnected
- (supplicant_iface_state_cb_handler): fold in the bits of
nm_device_802_11_wireless_reset_scan_interval() by resetting scan
interval to minimum
- (activation_success_handler): reset scan interval to something
reasonable
Modified:
trunk/ChangeLog
trunk/src/nm-device-802-11-wireless.c
trunk/src/nm-device-802-11-wireless.h
Modified: trunk/src/nm-device-802-11-wireless.c
==============================================================================
--- trunk/src/nm-device-802-11-wireless.c (original)
+++ trunk/src/nm-device-802-11-wireless.c Fri Feb 29 16:33:59 2008
@@ -148,7 +148,7 @@
};
-static void schedule_scan (NMDevice80211Wireless *self);
+static void schedule_scan (NMDevice80211Wireless *self, gboolean backoff);
static void cancel_pending_scan (NMDevice80211Wireless *self);
@@ -745,6 +745,8 @@
}
cancel_pending_scan (self);
+ /* Reset the scan interval to be pretty frequent when disconnected */
+ priv->scan_interval = SCAN_INTERVAL_MIN + SCAN_INTERVAL_STEP;
cleanup_association_attempt (self, TRUE);
@@ -972,20 +974,6 @@
return FALSE;
}
-
-void
-nm_device_802_11_wireless_reset_scan_interval (NMDevice80211Wireless *self)
-{
- NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
-
- g_return_if_fail (NM_IS_DEVICE_802_11_WIRELESS (self));
-
- priv->scan_interval = SCAN_INTERVAL_MIN;
-
- if (priv->pending_scan_id)
- schedule_scan (self);
-}
-
/*
* nm_device_get_mode
*
@@ -1452,31 +1440,36 @@
can_scan (NMDevice80211Wireless *self)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
- guint32 state;
- gboolean scan = FALSE;
-
- state = nm_supplicant_interface_get_connection_state (priv->supplicant.iface);
+ guint32 sup_state;
+ NMDeviceState dev_state;
+ gboolean is_disconnected = FALSE;
+
+ sup_state = nm_supplicant_interface_get_connection_state (priv->supplicant.iface);
+ dev_state = nm_device_get_state (NM_DEVICE (self));
+
+ is_disconnected = ( sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED
+ || sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE
+ || sup_state == NM_SUPPLICANT_INTERFACE_CON_STATE_SCANNING
+ || dev_state == NM_DEVICE_STATE_UNKNOWN
+ || dev_state == NM_DEVICE_STATE_DOWN
+ || dev_state == NM_DEVICE_STATE_DISCONNECTED
+ || dev_state == NM_DEVICE_STATE_FAILED
+ || dev_state == NM_DEVICE_STATE_CANCELLED) ? TRUE : FALSE;
- if (priv->num_freqs >= 14) {
- /* A/B/G cards should only scan if they are disconnected. */
- if (state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED ||
- state == NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE)
- scan = TRUE;
- } else if (state == NM_SUPPLICANT_INTERFACE_CON_STATE_DISCONNECTED ||
- state == NM_SUPPLICANT_INTERFACE_CON_STATE_INACTIVE ||
- state == NM_SUPPLICANT_INTERFACE_CON_STATE_COMPLETED)
- scan = TRUE;
+ /* All wireless devices can scan when disconnected */
+ if (is_disconnected)
+ return TRUE;
- return scan;
-}
+ /* Devices supporting only B/G frequencies can scan when disconnected
+ * and activated, but not when activating. We don't allow a/b/g devices to
+ * scan when activated, because there are just too many channels to scan and
+ * it takes too long to scan them, so users get angry when their SSH
+ * sessions lag.
+ */
+ if ((priv->num_freqs <= 14) && (dev_state == NM_DEVICE_STATE_ACTIVATED))
+ return TRUE;
-static void
-supplicant_iface_scan_result_cb (NMSupplicantInterface * iface,
- gboolean result,
- NMDevice80211Wireless * self)
-{
- if (can_scan (self))
- schedule_scan (self);
+ return FALSE;
}
static gboolean
@@ -1484,18 +1477,18 @@
{
NMDevice80211Wireless *self = NM_DEVICE_802_11_WIRELESS (user_data);
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
- gboolean success = TRUE;
+ gboolean backoff = FALSE;
if (can_scan (self)) {
-// nm_debug ("Starting wireless scan for device %s.",
-// nm_device_get_iface (NM_DEVICE (user_data)));
-
- success = nm_supplicant_interface_request_scan (priv->supplicant.iface);
- if (success)
- priv->pending_scan_id = 0;
+ if (nm_supplicant_interface_request_scan (priv->supplicant.iface)) {
+ /* success */
+ backoff = TRUE;
+ }
}
- return !success;
+ priv->pending_scan_id = 0;
+ schedule_scan (self, backoff);
+ return FALSE;
}
@@ -1506,25 +1499,37 @@
*
*/
static void
-schedule_scan (NMDevice80211Wireless *self)
+schedule_scan (NMDevice80211Wireless *self, gboolean backoff)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
- GTimeVal current_time;
+ GTimeVal now;
- g_get_current_time (¤t_time);
+ g_get_current_time (&now);
- /* Cancel the pending scan only if it would happen later than what is scheduled right now */
- if (priv->pending_scan_id && (current_time.tv_sec + priv->scan_interval < priv->scheduled_scan_time))
- cancel_pending_scan (self);
+ /* Cancel the pending scan if it would happen later than (now + the scan_interval) */
+ if (priv->pending_scan_id) {
+ if (now.tv_sec + priv->scan_interval < priv->scheduled_scan_time)
+ cancel_pending_scan (self);
+ }
+
+ if (!priv->pending_scan_id) {
+ guint factor = 2;
+
+ if ( nm_device_is_activating (NM_DEVICE (self))
+ || (nm_device_get_state (NM_DEVICE (self)) == NM_DEVICE_STATE_ACTIVATED))
+ factor = 1;
- if (!priv->pending_scan_id)
priv->pending_scan_id = g_timeout_add (priv->scan_interval * 1000,
request_wireless_scan,
self);
- priv->scheduled_scan_time = current_time.tv_sec + priv->scan_interval;
- if (priv->scan_interval < SCAN_INTERVAL_MAX)
- priv->scan_interval += SCAN_INTERVAL_STEP;
+ priv->scheduled_scan_time = now.tv_sec + priv->scan_interval;
+ if (backoff && (priv->scan_interval < (SCAN_INTERVAL_MAX / factor))) {
+ priv->scan_interval += (SCAN_INTERVAL_STEP / factor);
+ /* Ensure the scan interval will never be less than 20s... */
+ priv->scan_interval = MAX(priv->scan_interval, SCAN_INTERVAL_MIN + SCAN_INTERVAL_STEP);
+ }
+ }
}
@@ -1540,6 +1545,15 @@
}
+static void
+supplicant_iface_scan_result_cb (NMSupplicantInterface * iface,
+ gboolean result,
+ NMDevice80211Wireless * self)
+{
+ if (can_scan (self))
+ schedule_scan (self, TRUE);
+}
+
static gboolean
is_encrypted (guint32 flags, guint32 wpa_flags, guint32 rsn_flags)
{
@@ -1945,12 +1959,14 @@
{
struct state_cb_data * cb_data = (struct state_cb_data *) user_data;
NMDevice80211Wireless * self;
+ NMDevice80211WirelessPrivate *priv;
guint32 new_state, old_state;
g_return_val_if_fail (cb_data != NULL, FALSE);
self = cb_data->self;
- new_state = cb_data->new_state;
+ priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
+ new_state = cb_data->new_state;
old_state = cb_data->old_state;
nm_info ("(%s) supplicant interface is now in state %d (from %d).",
@@ -1959,8 +1975,8 @@
old_state);
if (new_state == NM_SUPPLICANT_INTERFACE_STATE_READY) {
- nm_device_802_11_wireless_reset_scan_interval (self);
- schedule_scan (self);
+ priv->scan_interval = SCAN_INTERVAL_MIN;
+ schedule_scan (self, TRUE);
} else if (new_state == NM_SUPPLICANT_INTERFACE_STATE_DOWN) {
cancel_pending_scan (self);
cleanup_association_attempt (self, FALSE);
@@ -2820,6 +2836,7 @@
activation_success_handler (NMDevice *dev)
{
NMDevice80211Wireless *self = NM_DEVICE_802_11_WIRELESS (dev);
+ NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
NMAccessPoint *ap;
struct ether_addr bssid = { {0x0, 0x0, 0x0, 0x0, 0x0, 0x0} };
NMAccessPoint *tmp_ap;
@@ -2871,6 +2888,9 @@
done:
periodic_update (self);
+
+ /* Reset scan interval to something reasonable */
+ priv->scan_interval = SCAN_INTERVAL_MIN + (SCAN_INTERVAL_STEP * 2);
}
Modified: trunk/src/nm-device-802-11-wireless.h
==============================================================================
--- trunk/src/nm-device-802-11-wireless.h (original)
+++ trunk/src/nm-device-802-11-wireless.h Fri Feb 29 16:33:59 2008
@@ -98,8 +98,6 @@
gboolean nm_device_802_11_wireless_set_mode (NMDevice80211Wireless *self,
const int mode);
-void nm_device_802_11_wireless_reset_scan_interval (NMDevice80211Wireless *dev);
-
int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *self);
gboolean nm_device_802_11_wireless_can_activate (NMDevice80211Wireless * self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]