From 4b11874390f20ab1bb8d5d6797463992738ce080 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Tue, 23 Jun 2015 17:12:51 +0100 Subject: [PATCH] sleep for 0.1s instead of 1s in the wait_for_status loop This reduces `weave launch|launch-dns` execution time. Closes #992. --- weave | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/weave b/weave index 9c6533d2..7b58efb1 100755 --- a/weave +++ b/weave @@ -183,6 +183,21 @@ command_exists() { command -v $1 >/dev/null 2>&1 } +fractional_sleep() { + case $1 in + *.*) + if [ -z "$NO_FRACTIONAL_SLEEP" ] ; then + sleep $1 >/dev/null 2>&1 && return 0 + NO_FRACTIONAL_SLEEP=1 + fi + sleep $((${1%.*} + 1)) + ;; + *) + sleep $1 + ;; + esac +} + run_iptables() { # -w is recent addition to iptables if [ -z "$CHECKED_IPTABLES_W" ] ; then @@ -585,7 +600,7 @@ wait_for_status() { echo "$err_msg" >&2 return 1 fi - sleep 1 + fractional_sleep 0.1 done }