Implement random wait to eliminate race.

This commit is contained in:
Slawomir Wojciech Wojtczak (vermaden) 2013-04-03 09:12:19 +02:00
parent 4506edf751
commit f27ca34a40
1 changed files with 11 additions and 1 deletions

View File

@ -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"