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>