From f27ca34a408d26df6968a057292a616851d0acd6 Mon Sep 17 00:00:00 2001 From: "Slawomir Wojciech Wojtczak (vermaden)" Date: Wed, 3 Apr 2013 09:12:19 +0200 Subject: [PATCH] Implement random wait to eliminate race. --- automount | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/automount b/automount index c8007c7..7f583e6 100755 --- a/automount +++ b/automount @@ -256,10 +256,20 @@ __wait_for_boot() { fi } -__wait_for_boot +__random_wait() { + RANDOM=$( head -c 256 /dev/urandom | env LC_ALL=C tr -c -d '1-9' ) + MODULO=$(( ${RANDOM} % 24 )) + WAIT=$( echo ${MODULO} / 10 | bc -l ) + WAIT=$( printf "%.1f" ${WAIT} ) + sleep ${WAIT} + __log "${DEV}: random wait for '${WAIT}' seconds before 'attach' action" +} DEV=/dev/${1} +__wait_for_boot +__random_wait + case ${2} in (attach) __log "${DEV}: attach"