mirror of
https://github.com/apache/cloudstack.git
synced 2025-12-17 11:04:00 +01:00
Otherwise it's easy to trigger the racy issue. This one just contained fix for reconfigLB.sh
45 lines
864 B
Bash
45 lines
864 B
Bash
#!/bin/bash
|
|
|
|
# getLockFile() parameters
|
|
# $1 lock filename
|
|
# $2 timeout seconds
|
|
getLockFile() {
|
|
__locked=0
|
|
__LOCKFILE="/tmp/$1.lock"
|
|
if [ $2 ]
|
|
then
|
|
__TIMEOUT=$2
|
|
else
|
|
__TIMEOUT=10
|
|
fi
|
|
|
|
for i in `seq 1 $__TIMEOUT`
|
|
do
|
|
if [ ! -e $__LOCKFILE ]
|
|
then
|
|
touch $__LOCKFILE
|
|
__locked=1
|
|
break
|
|
fi
|
|
sleep 1
|
|
logger -t cloud "sleep 1 second wait for the lock file " $__LOCKFILE
|
|
done
|
|
if [ $__locked -ne 1 ]
|
|
then
|
|
logger -t cloud "fail to acquire the lock file $__LOCKFILE after $__TIMEOUT seconds time out!"
|
|
fi
|
|
echo $__locked
|
|
}
|
|
|
|
# releaseLockFile() parameters
|
|
# $1 lock filename
|
|
# $2 locked(1) or not(0)
|
|
releaseLockFile() {
|
|
__LOCKFILE="/tmp/$1.lock"
|
|
__locked=$2
|
|
if [ "$__locked" == "1" ]
|
|
then
|
|
rm $__LOCKFILE
|
|
fi
|
|
}
|