Changeset 1665

Show
Ignore:
Timestamp:
07/04/06 12:20:36 (3 years ago)
Author:
kelmo
Message:

There is an apparent race condition between scanning and changing
mode. When active scanning changing the mode (iwpriv athX mode Y)
will either work immediately, or will have no effect until a scan
is manually prompted (iwlist athX scan) at which point it changes
to the new mode prior to commencing the scan. If the scanning
debug output is turned on (80211debug +scan) then the change in
mode always occurs immediately.

This patch spins on the flag IEEE80211_F_SCAN which indicates the
scan has been cancelled inside ieee80211_ioctl_setmode() and
delays a short time if the flag indicates the scan is still
running.

At present, the solution is this: Make the max timeout value 100ms,
which should be fine for 99.9% of the time (cancel_scan should, in
theory, only take a maximum of 10ms to fire). However, if cancel_scan
does time out (or another scan is started between cancel_scan firing
and us noticing the cancellation of the scan), then there is a
problem.

Closes #228

Signed-off-by: Ian M. Rawley <imr1@waikato.ac.nz>
Signed-off-by: Scott Raynel <scottraynel@gmail.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/net80211/ieee80211_wireless.c

    r1664 r1665  
    17811781        struct ifreq ifr; 
    17821782        char s[6];              /* big enough for ``11adt'' */ 
    1783         int retv, mode, ifr_mode
     1783        int retv, mode, ifr_mode, itr_count
    17841784 
    17851785        if (ic->ic_media.ifm_cur == NULL) 
     
    18171817                if (IS_UP_AUTO(vap)) { 
    18181818                        ieee80211_cancel_scan(vap); 
     1819                        itr_count = 0; 
     1820                        while((ic->ic_flags & IEEE80211_F_SCAN) != 0) { 
     1821                                mdelay(1); 
     1822                                if (itr_count < 100) { 
     1823                                        itr_count++; 
     1824                                        continue; 
     1825                                } 
     1826                                IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, 
     1827                                  "%s: Timeout cancelling current scan.\n", 
     1828                                  __func__); 
     1829                                return -ETIMEDOUT; 
     1830                        } 
    18191831                        ieee80211_new_state(vap, IEEE80211_S_SCAN, 0); 
    18201832                }