On 7/30/2018 6:11 PM, Matt Darfeuille wrote:
> On 7/28/2018 5:19 PM, Tom Eastep wrote:
>> On 07/28/2018 08:16 AM, Brian J. Murrell wrote:
>>> On Sat, 2018-07-28 at 08:03 -0700, Tom Eastep wrote:
>>>> diff --git a/Shorewall-core/lib.common b/Shorewall-core/lib.common
>>>> index 205fc705f..bbebf0936 100644
>>>> --- a/Shorewall-core/lib.common
>>>> +++ b/Shorewall-core/lib.common
>>>> @@ -751,6 +751,8 @@ mutex_on()
>>>> lockf=${LOCKFILE:=${VARDIR}/lock}
>>>> local lockpid
>>>> local lockd
>>>> + local lockbin
>>>> + local openwrt
>>>>
>>>> MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
>>>>
>>>> @@ -760,28 +762,33 @@ mutex_on()
>>>>
>>>> [ -d "$lockd" ] || mkdir -p "$lockd"
>>>>
>>>> + lockbin=$(qt mywhich lock)
>>>> + openwrt=[ -n "$openwrt" -a -h "$openwrt" ]
>>>
>>> Did you mean:
>>>
>>> + openwrt=[ -n "$lockbin" -a -h "$lockbin" ]
>>>
>>> here?
>>>
>>
>> Yes.
>>
>
> With both patch applied (MUTEX_ON.patch and MUTEX_ON1.patch) and the
> above correction I get:
>
> root@LEDE:~# shorewall-lite restart
> /sbin/shorewall-lite: line 14: -n: not found
> WARNING: Stale lockfile /lib/shorewall-lite/lock from pid 854 removed
> Stopping Shorewall Lite....
>
> What am I missing ?
>
Ok -- Here's my take on the above:
The attached patch (MUTEX_ON_TAKE1.patch) includes:
- MUTEX_ON.patch
- MUTEX_ON1.patch
- The above correction (changing 'openwrt' to 'lockbin')
- My take on fixing the above error ( "/sbin/shorewall-lite: line 14:
-n: not found")
Brian/Tom, thoughts?
-Matt
--
Matt Darfeuille
diff --git a/Shorewall-core/lib.common b/Shorewall-core/lib.common
index c373a31ad..36800c887 100644
--- a/Shorewall-core/lib.common
+++ b/Shorewall-core/lib.common
@@ -751,6 +751,8 @@ mutex_on()
lockf=${LOCKFILE:=${VARDIR}/lock}
local lockpid
local lockd
+ local lockbin
+ local openwrt
MUTEX_TIMEOUT=${MUTEX_TIMEOUT:-60}
@@ -760,29 +762,33 @@ mutex_on()
[ -d "$lockd" ] || mkdir -p "$lockd"
+ lockbin=$(qt mywhich lock)
+ [ -n "$lockbin" -a -h "$lockbin" ] && openwrt=Yes || openwrt=
+
if [ -f $lockf ]; then
lockpid=`cat ${lockf} 2> /dev/null`
if [ -z "$lockpid" ] || [ $lockpid = 0 ]; then
rm -f ${lockf}
error_message "WARNING: Stale lockfile ${lockf} removed"
- elif [ $lockpid -eq $$ ]; then
- return 0
- elif ! ps | grep -v grep | qt grep ${lockpid}; then
- rm -f ${lockf}
- error_message "WARNING: Stale lockfile ${lockf} from pid
${lockpid} removed"
+ elif [ -z "$openwrt" ]; then
+ if [ $lockpid -eq $$ ]; then
+ fatal_error "Mutex_on confusion"
+ elif ! qt ps --pid ${lockpid}; then
+ rm -f ${lockf}
+ error_message "WARNING: Stale lockfile ${lockf} from pid
${lockpid} removed"
+ fi
fi
fi
- if qt mywhich lockfile; then
- lockfile -${MUTEX_TIMEOUT} -r1 ${lockf}
+ if [ -n "$openwrt" ]; then
+ lock ${lockf} || fatal_error "Can't lock ${lockf}"
+ g_havemutex="lock -u ${lockf}"
+ elif qt mywhich lockfile; then
+ lockfile -${MUTEX_TIMEOUT} -r1 ${lockf} || fatal_error "Can't lock
${lockf}"
g_havemutex="rm -f ${lockf}"
chmod u+w ${lockf}
echo $$ > ${lockf}
chmod u-w ${lockf}
- elif qt mywhich lock; then
- lock ${lockf}
- g_havemutex="lock -u ${lockf} && rm -f ${lockf}"
- chmod u=r ${lockf}
else
while [ -f ${lockf} -a ${try} -lt ${MUTEX_TIMEOUT} ] ; do
sleep 1
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Shorewall-users mailing list
Shorewall-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/shorewall-users