summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Hallberg <henrik@k2h.se>2012-07-03 03:11:12 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-07-03 03:34:34 +0200
commit2a97de914054140b93e5eb163c2da73ec5001ee3 (patch)
tree61fc96f8835f86f8991a451b8d8e132f3af40ba8
parent294a65132b88324d3ed917635fa84cf42f0a90f7 (diff)
downloadnetctl-2a97de914054140b93e5eb163c2da73ec5001ee3.tar.gz
netctl-2a97de914054140b93e5eb163c2da73ec5001ee3.tar.xz
Wait actively in {start, stop}_wpa
Check .pid file regularly instead of waiting a second blindly. Saves up to a second of wall time per call.
-rw-r--r--src/8021x14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/8021x b/src/8021x
index d143b30..e5047a2 100644
--- a/src/8021x
+++ b/src/8021x
@@ -38,21 +38,19 @@ start_wpa()
fi
wpa_supplicant -B -P "/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -D "$WPA_DRIVER" "$WPA_CONF" $WPA_OPTS
- sleep 1
- if [[ ! -f "/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
- return 1
- fi
+ # wait up to one second for the pid file to appear
+ timeout_wait 1 '[[ -f "/run/wpa_supplicant_${INTERFACE}.pid" ]]';
+ return $?
}
stop_wpa()
{
wpa_cli -p "$WPA_CTRL_PATH" -i "$1" terminate &> /dev/null
- sleep 1 # JP: need this else the file tends to disappear after [[ -f ... ]] but before cat...
- # see <http://bbs.archlinux.org/viewtopic.php?pid=515667#p515667>
- if [[ -f "/run/wpa_supplicant_$1.pid" ]]; then
+
+ # wait up to one second for the pid file to be removed
+ timeout_wait 1 '[[ ! -f "/run/wpa_supplicant_$1.pid" ]]' || \
kill "$(< "/run/wpa_supplicant_$1.pid")" &>/dev/null &
- fi
}
wpa_reconfigure() {