ref: 0b950d557452938190be64ddcde1d9e30f6e9c67
parent: b502c2e324fc96405044ecfe8cb0c7af64a97211
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Jul 18 11:30:53 EDT 2013
wifi: make "auth" command non-blocking, let aux/wpa do the waiting for bss scan to complete.
--- a/sys/src/9/pc/wifi.c
+++ b/sys/src/9/pc/wifi.c
@@ -766,7 +766,6 @@
Cmdtab *ct;
Wnode *wn;
Wkey *k;
- int i;
cb = nil;
if(waserror()){@@ -818,16 +817,6 @@
setstatus(wifi, wn, Sconn);
sendauth(wifi, wn);
}
- /* wait 3 seconds for authentication response */
- for(i=0; i < 30; i++){- if(wifi->bss != nil)
- goto done;
- if(!waserror()){- tsleep(&up->sleep, return0, 0, 100);
- poperror();
- }
- }
- error("connect timeout");break;
case CMbssid:
memmove(wifi->bssid, addr, Eaddrlen);
@@ -859,7 +848,6 @@
setstatus(wifi, wn, Sassoc);
break;
}
-done:
poperror();
free(cb);
return n;
--- a/sys/src/cmd/aux/wpa.c
+++ b/sys/src/cmd/aux/wpa.c
@@ -531,7 +531,7 @@
char addr[128];
uchar *rsne;
int rsnelen;
- int n;
+ int n, try;
quotefmtinstall();
fmtinstall('H', Hfmt);@@ -617,11 +617,14 @@
fprint(2, "rsne: %.*H\n", rsnelen, rsne);
/*
- * we use write() instead of fprint so message gets written
- * at once and not chunked up on fprint buffer.
+ * we use write() instead of fprint so the message gets written
+ * at once and not chunked up on fprint buffer. bss scan might
+ * not be complete yet, so retry for 10 seconds.
*/
n = sprint((char*)buf, "auth %.*H", rsnelen, rsne);
- if(write(cfd, buf, n) != n)
+ for(try = 10; try >= 0 && write(cfd, buf, n) != n; try--)
+ sleep(1000);
+ if(try < 0)
sysfatal("write auth: %r"); if(!debug){--
⑨