]> git.plutz.net Git - serve0/commitdiff
Merge commit '3a4d7121502a5f4817a0b6ba5f871ead6cffeb63'
authorPaul Hänsch <paul@plutz.net>
Mon, 23 Aug 2021 15:33:08 +0000 (17:33 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 23 Aug 2021 15:33:08 +0000 (17:33 +0200)
1  2 
cgilite/storage.sh

diff --combined cgilite/storage.sh
index c0f9076a2e9ebc02b8db3db9f9d52da12ba4ca46,77ee29c06243eae9359c03125626a46f498cded4..77ee29c06243eae9359c03125626a46f498cded4
@@@ -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"
      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