diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-15 16:56:19 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2004-07-15 16:56:19 +0000 |
commit | 981e33d8ec0902d4189b1b94a4cb99dc67077294 (patch) | |
tree | 262929d84cdb0bc17d43c5bafb33869bf0fafcb7 | |
parent | 3dd552c5bd42aa43602e0d971f18e40676ab90da (diff) |
Keep trying if we get EINPROGRESS from SIOCGWAVELAN, up to 10 times.
-rw-r--r-- | sbin/wicontrol/wicontrol.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sbin/wicontrol/wicontrol.c b/sbin/wicontrol/wicontrol.c index 343e48f383c..651c38a2f27 100644 --- a/sbin/wicontrol/wicontrol.c +++ b/sbin/wicontrol/wicontrol.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wicontrol.c,v 1.51 2004/07/15 16:38:57 millert Exp $ */ +/* $OpenBSD: wicontrol.c,v 1.52 2004/07/15 16:56:18 millert Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -68,7 +68,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997, 1998, 1999\ Bill Paul. All rights reserved."; static const char rcsid[] = - "@(#) $OpenBSD: wicontrol.c,v 1.51 2004/07/15 16:38:57 millert Exp $"; + "@(#) $OpenBSD: wicontrol.c,v 1.52 2004/07/15 16:56:18 millert Exp $"; #endif int wi_getval(char *, struct wi_req *); @@ -105,20 +105,23 @@ int wi_getval(char *iface, struct wi_req *wreq) { struct ifreq ifr; - int error, s; - - bzero((char *)&ifr, sizeof(ifr)); - - strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); - ifr.ifr_data = (caddr_t)wreq; + int error = 0, i, s; s = socket(AF_INET, SOCK_DGRAM, 0); if (s == -1) err(1, "socket"); - if ((error = ioctl(s, SIOCGWAVELAN, &ifr)) == -1) - warn("SIOCGWAVELAN (0x%x)", wreq->wi_type); + for (i = 10; --i; sleep(1)) { + bzero((char *)&ifr, sizeof(ifr)); + strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)); + ifr.ifr_data = (caddr_t)wreq; + error = ioctl(s, SIOCGWAVELAN, &ifr); + if (error != -1 || errno != EINPROGRESS) + break; + } + if (error == -1) + warn("SIOCGWAVELAN (0x%x)", wreq->wi_type); close(s); return (error); } |