forked from extern/shorewall_code
Protect against MUTEX_TIMEOUT=0
git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@154 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb
This commit is contained in:
parent
1c235e096d
commit
7ae7fc3089
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Shorewall 1.3 -- /var/lib/shorewall/functions
|
# Shorewall 1.3 -- /var/lib/shorewall/functions
|
||||||
|
|
||||||
@ -118,30 +119,28 @@ get_statedir()
|
|||||||
mutex_on()
|
mutex_on()
|
||||||
{
|
{
|
||||||
local try=0
|
local try=0
|
||||||
local max=
|
|
||||||
local int=1
|
|
||||||
|
|
||||||
local lockf=$STATEDIR/lock
|
local lockf=$STATEDIR/lock
|
||||||
|
|
||||||
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
||||||
|
|
||||||
max=${MUTEX_TIMEOUT}
|
if [ $MUTEX_TIMEOUT -gt 0 ]; then
|
||||||
|
|
||||||
[ -d $STATEDIR ] || mkdir -p $STATEDIR
|
[ -d $STATEDIR ] || mkdir -p $STATEDIR
|
||||||
|
|
||||||
if qt which lockfile; then
|
if qt which lockfile; then
|
||||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||||
else
|
else
|
||||||
while [ -f ${lockf} -a ${try} -lt ${max} ] ; do
|
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||||
sleep ${int}
|
sleep 1
|
||||||
try=$((${try} + 1))
|
try=$((${try} + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${try} -lt ${max} ] ; then
|
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
|
||||||
# Create the lockfile
|
# Create the lockfile
|
||||||
echo $$ > ${lockf}
|
echo $$ > ${lockf}
|
||||||
else
|
else
|
||||||
echo "Giving up on lock file ${lockf}" >&2
|
echo "Giving up on lock file ${lockf}" >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Shorewall 1.3 -- /var/lib/shorewall/functions
|
# Shorewall 1.3 -- /var/lib/shorewall/functions
|
||||||
|
|
||||||
@ -118,30 +119,28 @@ get_statedir()
|
|||||||
mutex_on()
|
mutex_on()
|
||||||
{
|
{
|
||||||
local try=0
|
local try=0
|
||||||
local max=
|
|
||||||
local int=1
|
|
||||||
|
|
||||||
local lockf=$STATEDIR/lock
|
local lockf=$STATEDIR/lock
|
||||||
|
|
||||||
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
|
||||||
|
|
||||||
max=${MUTEX_TIMEOUT}
|
if [ $MUTEX_TIMEOUT -gt 0 ]; then
|
||||||
|
|
||||||
[ -d $STATEDIR ] || mkdir -p $STATEDIR
|
[ -d $STATEDIR ] || mkdir -p $STATEDIR
|
||||||
|
|
||||||
if qt which lockfile; then
|
if qt which lockfile; then
|
||||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||||
else
|
else
|
||||||
while [ -f ${lockf} -a ${try} -lt ${max} ] ; do
|
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||||
sleep ${int}
|
sleep 1
|
||||||
try=$((${try} + 1))
|
try=$((${try} + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ ${try} -lt ${max} ] ; then
|
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
|
||||||
# Create the lockfile
|
# Create the lockfile
|
||||||
echo $$ > ${lockf}
|
echo $$ > ${lockf}
|
||||||
else
|
else
|
||||||
echo "Giving up on lock file ${lockf}" >&2
|
echo "Giving up on lock file ${lockf}" >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user