mirror of
https://gitlab.com/shorewall/code.git
synced 2024-11-22 07:33:43 +01:00
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
|
||||
|
||||
@ -118,30 +119,28 @@ get_statedir()
|
||||
mutex_on()
|
||||
{
|
||||
local try=0
|
||||
local max=
|
||||
local int=1
|
||||
|
||||
local lockf=$STATEDIR/lock
|
||||
|
||||
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
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||
else
|
||||
while [ -f ${lockf} -a ${try} -lt ${max} ] ; do
|
||||
sleep ${int}
|
||||
try=$((${try} + 1))
|
||||
if qt which lockfile; then
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||
else
|
||||
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||
sleep 1
|
||||
try=$((${try} + 1))
|
||||
done
|
||||
|
||||
if [ ${try} -lt ${max} ] ; then
|
||||
# Create the lockfile
|
||||
echo $$ > ${lockf}
|
||||
else
|
||||
echo "Giving up on lock file ${lockf}" >&2
|
||||
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
|
||||
# Create the lockfile
|
||||
echo $$ > ${lockf}
|
||||
else
|
||||
echo "Giving up on lock file ${lockf}" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Shorewall 1.3 -- /var/lib/shorewall/functions
|
||||
|
||||
@ -118,30 +119,28 @@ get_statedir()
|
||||
mutex_on()
|
||||
{
|
||||
local try=0
|
||||
local max=
|
||||
local int=1
|
||||
|
||||
local lockf=$STATEDIR/lock
|
||||
|
||||
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
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||
else
|
||||
while [ -f ${lockf} -a ${try} -lt ${max} ] ; do
|
||||
sleep ${int}
|
||||
try=$((${try} + 1))
|
||||
if qt which lockfile; then
|
||||
lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
|
||||
else
|
||||
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
|
||||
sleep 1
|
||||
try=$((${try} + 1))
|
||||
done
|
||||
|
||||
if [ ${try} -lt ${max} ] ; then
|
||||
# Create the lockfile
|
||||
echo $$ > ${lockf}
|
||||
else
|
||||
echo "Giving up on lock file ${lockf}" >&2
|
||||
if [ ${try} -lt ${MUTEX_TIMEOUT} ] ; then
|
||||
# Create the lockfile
|
||||
echo $$ > ${lockf}
|
||||
else
|
||||
echo "Giving up on lock file ${lockf}" >&2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user