From dd493b1e4f116d26398edd5eea342089e60568e7 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 12 Sep 2020 22:47:10 -0700 Subject: [PATCH] *-util-functions.sh: genericize v_lock_gc into v_lock_file Rename v_lock_gc function in updategc-util-functions.sh to v_lock_file and add an additional parameter to specify the name of the lock file to create. Add a v_lock_gc function back to gc-util-functions.sh that calls the new v_lock_file function with "gc.pid" as the second argument. This makes the lock file functionality available for future use with file names other than "gc.pid". Signed-off-by: Kyle J. McKay --- jobd/gc-util-functions.sh | 10 ++++++++++ jobd/updategc-util-functions.sh | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/jobd/gc-util-functions.sh b/jobd/gc-util-functions.sh index 3bbf24a..ef47ef2 100755 --- a/jobd/gc-util-functions.sh +++ b/jobd/gc-util-functions.sh @@ -14,6 +14,16 @@ packopts="--depth=50 --window=50 --window-memory=${var_window_memory:-1g}" quiet="-q"; [ "${show_progress:-0}" = "0" ] || quiet= +# Create a gc.pid lockfile +# $1 => name of variable to store result in +# On success: +# variable named by $1 will contain the name of the newly create lockfile (i.e. "gc.pid") +# On failure: +# variable named by $1 will contain the failure reason +v_lock_gc() { + v_lock_file "$1" "gc.pid" +} + # make sure combine-packs uses the correct Git executable run_combine_packs() { PATH="$var_git_exec_path:$cfg_basedir/bin:$PATH" @basedir@/jobd/combine-packs.sh "$@" diff --git a/jobd/updategc-util-functions.sh b/jobd/updategc-util-functions.sh index 843a96b..d76db90 100755 --- a/jobd/updategc-util-functions.sh +++ b/jobd/updategc-util-functions.sh @@ -43,15 +43,16 @@ createlock() { return 1 } -# Create a gc.pid lockfile +# Create a new lockfile # $1 => name of variable to store result in +# $2 => name of the new lockfile (default is "lockfile.pid") # On success: -# variable named by $1 will contain the name of the newly create lockfile (i.e. "gc.pid") +# variable named by $1 will contain the name of the newly create lockfile (i.e. "$2") # On failure: # variable named by $1 will contain the failure reason -v_lock_gc() { +v_lock_file() { # be compatibile with gc.pid file from newer Git releases - _lockf='gc.pid' + _lockf="${2:-lockfile.pid}" _hn="$(hostname)" _active= if [ "$(createlock "$_lockf")" ]; then -- 2.11.4.GIT