From 5b1d7ff5b9c42bed0bcdfcb42ff2f5bb799562fc Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 17 Jul 2023 20:55:55 +0200 Subject: lib/intentions-queue: make execute_all_intentions() locking * now, it's safe to call it in almost all places * this enables us to do it at the start of many scripts, potentially cleaning up old left-over intentions --- lib/intentions-queue | 8 ++++++++ lib/load-configuration | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'lib') diff --git a/lib/intentions-queue b/lib/intentions-queue index 61ec4f3..f244e1b 100755 --- a/lib/intentions-queue +++ b/lib/intentions-queue @@ -92,7 +92,15 @@ intentions_left() { # execute_all_intentions # executes all intentions execute_all_intentions() { + exec 6> "${intentions_lock_file}" + if ! verbose_flock 6; then + >&2 echo 'someone already executes intentions - no need to schedule a second run' + return + fi + while intentions_left -n; do execute_intention done + + flock -u 6 } diff --git a/lib/load-configuration b/lib/load-configuration index cc9fe7f..e7af638 100755 --- a/lib/load-configuration +++ b/lib/load-configuration @@ -174,6 +174,10 @@ if [ -z "${harvest_commit_times_lock_file}" ]; then harvest_commit_times_lock_file="${work_dir}/harvest-commit-times.lock" fi +if [ -z "${intentions_lock_file}" ]; then + intentions_lock_file="${work_dir}/intentions.lock" +fi + if [ -z "${package_database_lock_file}" ]; then package_database_lock_file="${work_dir}/package-database.lock" fi -- cgit v1.2.3-54-g00ecf