From: Paul Hänsch Date: Mon, 23 Aug 2021 15:33:08 +0000 (+0200) Subject: Merge commit '3a4d7121502a5f4817a0b6ba5f871ead6cffeb63' X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=f307cfa12e5dbdd445ca787011eefbefd5c47dc5;hp=-c;p=serve0 Merge commit '3a4d7121502a5f4817a0b6ba5f871ead6cffeb63' --- f307cfa12e5dbdd445ca787011eefbefd5c47dc5 diff --combined cgilite/storage.sh index c0f9076,77ee29c..77ee29c --- a/cgilite/storage.sh +++ b/cgilite/storage.sh @@@ -1,6 -1,6 +1,6 @@@ #!/bin/sh - # Copyright 2018, 2019 Paul Hänsch + # Copyright 2018, 2019, 2021 Paul Hänsch # # This is a file format helper, part of CGIlite. # @@@ -25,9 -25,7 +25,7 @@@ BR= ' LOCK(){ - local lock timeout block - lock="${1}.lock" - timeout="${2-20}" + local lock="${1}.lock" timeout="${2-20}" block if [ \! -w "${lock%/*}" ] || [ -e "$lock" -a \! -f "$lock" ]; then debug "Impossible to get lock: $lock" @@@ -40,14 -38,14 +38,14 @@@ if [ "$block" = $$ ]; then return 0 elif ! { ps -eo pid |grep -qwF "$block"; }; then - debug "Overriding stale lock: $lock" + debug "Trying to override stale lock: $lock" if LOCK "$lock" 1; then rm -- "$lock" RELEASE "$lock" fi else timeout=$((timeout - 1)) - sleep 1 + [ $timeout -gt 0 ] && sleep 1 fi done @@@ -56,8 -54,7 +54,7 @@@ } RELEASE(){ - local lock block - lock="${1}.lock" + local lock="${1}.lock" block read block <"$lock" if [ "$block" = $$ ]; then