From 48789abfb13b0713aeb5c60e7be3961322ce6181 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Fri, 14 Mar 2008 09:55:33 +0100 Subject: [PATCH 1/1] add and fix locking --- bin/release-delayed-messages | 9 +++++++++ bin/resubmit-postponed-messages | 9 +++++++++ bin/retrain | 5 +++-- bin/send-outgoing | 5 +++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/bin/release-delayed-messages b/bin/release-delayed-messages index 61abd85..cdb6da4 100755 --- a/bin/release-delayed-messages +++ b/bin/release-delayed-messages @@ -5,5 +5,14 @@ DELAYED_QUEUE=$HOME/.maildir/.delayed DIR="${0%/*}" +VAR=$HOME/.var/procmail +ME="${0##*/}" +LOCKFILE="$VAR/.$ME.lock" +trap "rm -f $LOCKFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then + echo "E: another $ME process is already running over that Maildir." >&2 + exit 1 +fi + "$DIR"/list-postponed-messages --all "$DELAYED_QUEUE" \ | exec xargs "$DIR"/resubmit --list diff --git a/bin/resubmit-postponed-messages b/bin/resubmit-postponed-messages index 1ea3100..df5663e 100755 --- a/bin/resubmit-postponed-messages +++ b/bin/resubmit-postponed-messages @@ -6,5 +6,14 @@ TICKLER_QUEUE=$HOME/.maildir/.store DIR="${0%/*}" +VAR=$HOME/.var/procmail +ME="${0##*/}" +LOCKFILE="$VAR/.$ME.lock" +trap "rm -f $LOCKFILE" 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 +if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then + echo "E: another $ME process is already running over that Maildir." >&2 + exit 1 +fi + "$DIR"/list-postponed-messages "$TICKLER_QUEUE" "$DELAYED_QUEUE" \ | exec xargs "$DIR"/resubmit --list diff --git a/bin/retrain b/bin/retrain index 784f17e..e7acbea 100755 --- a/bin/retrain +++ b/bin/retrain @@ -49,10 +49,11 @@ case "$HAM/$SPAM" in esac if [ -n "$maildir" ]; then - LOCKFILE="$maildir/.retrain.lock" + ME="${0##*/}" + LOCKFILE="$maildir/.$ME.lock" trap "rm -f $LOCKFILE" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then - echo "E: another retrain process is already running over that Maildir." >&2 + echo "E: another $ME process is already running over that Maildir." >&2 exit 1 fi diff --git a/bin/send-outgoing b/bin/send-outgoing index 244218f..1d5f800 100755 --- a/bin/send-outgoing +++ b/bin/send-outgoing @@ -7,10 +7,11 @@ DISCARD_RECORD=~/.maildir/.discard DONT_STORE=1 -LOCKFILE="$OUTBOX/.sendmail.lock" +ME="${0##*/}" +LOCKFILE="$OUTBOX/.$ME.lock" trap "rm -f $LOCKFILE" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 if ! lockfile -0 -r0 -l 3600 "$LOCKFILE" 2>/dev/null; then - echo "E: another sendmail process is already running over that Maildir." >&2 + echo "E: another $ME process is already running over that Maildir." >&2 exit 1 fi -- 2.39.5