summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2012-11-01 02:57:48 +0100
committerDave Reisner <dreisner@archlinux.org>2012-11-24 00:01:34 +0100
commit42c01012e85646706bf11042cc0952d47d9236d0 (patch)
treef01e026d87a3c3c22668d5fbbbe2f507ecb7ac74 /init_functions
parent1603e30f49347525dfcc999e3c63cb27cb54dde8 (diff)
downloadmkinitcpio-42c01012e85646706bf11042cc0952d47d9236d0.tar.gz
mkinitcpio-42c01012e85646706bf11042cc0952d47d9236d0.tar.xz
init: use exponential backoff in poll_device
Start at .1 second and double the interval, capping at 1s. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions16
1 files changed, 13 insertions, 3 deletions
diff --git a/init_functions b/init_functions
index 3ac0588..2bd07bd 100644
--- a/init_functions
+++ b/init_functions
@@ -11,14 +11,24 @@ poll_device() {
local device=$1 seconds=${2//[!0-9]}
[ -z "$seconds" ] && seconds=10
+ deciseconds=$(( seconds * 10 ))
+
+ # tenths of a second
+ sleepinterval=1
[ -b "$device" ] && return 0
if [ "$udevd_running" -eq 1 ]; then
msg "Waiting $seconds seconds for device $device ..." >&2
- while [ ! -b "$device" -a "$seconds" -gt 0 ]; do
- sleep 1
- seconds=$(( $seconds - 1 ))
+ while [ ! -b "$device" -a "$deciseconds" -gt 0 ]; do
+ if [ "$sleepinterval" -ge 10 ]; then
+ sleep 1
+ deciseconds=$(( deciseconds - 10 ))
+ else
+ sleep .$sleepinterval
+ deciseconds=$(( deciseconds - sleepinterval ))
+ sleepinterval=$(( sleepinterval * 2 ))
+ fi
done
fi