aboutsummaryrefslogtreecommitdiffstats
path: root/wpaspy/wpaspy.py
diff options
context:
space:
mode:
authorJouni Malinen <jouni@qca.qualcomm.com>2014-04-28 12:31:25 (GMT)
committerJouni Malinen <j@w1.fi>2014-04-28 13:54:09 (GMT)
commit19318861a527bf09f6deb02579597d4e95aaeeb4 (patch)
treea29049892ad910d1480b0cae8a6a6a27dc999636 /wpaspy/wpaspy.py
parentb7a6702fd47e82af0f5bb4a4444e46d3f25eaefa (diff)
downloadhostap-19318861a527bf09f6deb02579597d4e95aaeeb4.zip
hostap-19318861a527bf09f6deb02579597d4e95aaeeb4.tar.gz
hostap-19318861a527bf09f6deb02579597d4e95aaeeb4.tar.bz2
wpaspy: Handle DETACH response more robustly
There could be pending unsolicited event messages on the monitor socket when the DETACH command is issued. As such, the response may be something else then OK even if the actual detach operation succeeded. Try to avoid this be dropping pending messages before issuing the detach command. As an additional workaround, check the response against FAIL instead of requiring OK so that the self.attached does not get left to True incorrectly even if an additional event message were to be received. Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Diffstat (limited to 'wpaspy/wpaspy.py')
-rw-r--r--wpaspy/wpaspy.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py
index 9494305..2f57d74 100644
--- a/wpaspy/wpaspy.py
+++ b/wpaspy/wpaspy.py
@@ -39,6 +39,7 @@ class Ctrl:
self.detach()
except Exception, e:
# Need to ignore this allow the socket to be closed
+ self.attached = False
pass
if self.started:
self.s.close()
@@ -64,8 +65,10 @@ class Ctrl:
def detach(self):
if not self.attached:
return None
+ while self.pending():
+ ev = self.recv()
res = self.request("DETACH")
- if "OK" in res:
+ if "FAIL" not in res:
self.attached = False
return None
raise Exception("DETACH failed")