]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
wpaspy: Fix tracking of attached status
authorJouni Malinen <j@w1.fi>
Mon, 30 Dec 2013 20:23:18 +0000 (22:23 +0200)
committerJouni Malinen <j@w1.fi>
Tue, 31 Dec 2013 07:29:14 +0000 (09:29 +0200)
The attached variable was initialized and checked, but never updated.
Fix that by updating it on successful ATTACH/DETACH command.

Signed-hostap: Jouni Malinen <j@w1.fi>

wpaspy/wpaspy.py

index 678695f191539e948ffddcd698bcc8d2bb784021..9836c2df5763383a08bb861d73c5748ec4946f50 100644 (file)
@@ -30,7 +30,11 @@ class Ctrl:
 
     def close(self):
         if self.attached:
-            self.detach()
+            try:
+                self.detach()
+            except Exception, e:
+                # Need to ignore this allow the socket to be closed
+                pass
         if self.started:
             self.s.close()
             os.unlink(self.local)
@@ -48,6 +52,7 @@ class Ctrl:
             return None
         res = self.request("ATTACH")
         if "OK" in res:
+            self.attached = True
             return None
         raise Exception("ATTACH failed")
 
@@ -56,6 +61,7 @@ class Ctrl:
             return None
         res = self.request("DETACH")
         if "OK" in res:
+            self.attached = False
             return None
         raise Exception("DETACH failed")