procmail
[Top] [All Lists]

lock file to write cache with formail is not working

2008-01-29 11:06:19
Greetings,

I have the two recipes below. The first is called by procmail.rc, was
written by Sean Straw and, AFAICT, I didn't change it at all, so it
should work. The second, which I derived from the first, is one that I
run periodically from a shell script, like this:

for FILE in (all the files into a maildir cur and new subfolders)
  do
  /usr/bin/procmail -m $RC_FILES/every_minute.rc < ${FILE}

the purpose of the instruction above is to update ignore.cache with
all the msgids of the files in the IRR maildir, since that's where I
put messages with I consider irrelevant.

The problem I have is that ignore.cache is corrupted, that is it seems
partially overwritten every time like if the lock wasn't working:

#>  more ignore.cache

<748DB8BD55C9AC4FB9FC5A539E77CB561B78AE(_at_)super-srvr(_dot_)jmtg(_dot_)local>040103(_at_)netoyen(_dot_)net>10(_dot_)24482(_at_)gannon(_dot_)phys(_dot_)uwm(_dot_)edu>479F4B60(_dot_)1030608(_at_)animezone(_dot_)org>1621970(_dot_)squirrel(_at_)webmail(_dot_)linuxpowered(_dot_)net>er.gmane.org>6180(_dot_)24482(_at_)gannon(_dot_)phys(_dot_)uwm(_dot_)edu>01290809h67efcab4wfadf177e4852ffbf(_at_)mail(_dot_)gmail(_dot_)com>0102(_at_)ng23(_dot_)net>b230801290819j1f3d3879gc8add6fc1791cc3c(_at_)mail(_dot_)gmail(_dot_)com>l.gmail.com>ovak.net>(_dot_)1201624340(_dot_)squirrel(_at_)webmail(_dot_)linuxpowered(_dot_)net>29203(_dot_)squirrel(_at_)webmail(_dot_)linuxpowered(_dot_)net>

See what I mean? Only the leftmost MSGID is complete. Consequently,
the first recipe below doesn't block many recognizes many replies to
irrelevant messages (since the corresponding MSGIDS aren't written
properly into ignore.cache)

Why is this happening? Which lock conditions should I change? BTW,
this is happening on Centos 4.6

TIA,
                Marco

##################################################################
RECIPE 1 by Sean Straw:

#==========================================================================
# simple recipe to ignore threads based on prior cache of threads to ignore.
# 20061230, SBS
# it is INCLUDEd by procmail.rc

# get In-Reply-To messageid, check to see if it is in the ignore cache or
# in the mua_ignore cache.  formail stores cache with ascii-z terminations,
# but grep will still match the binary file.
# if we have a match in the MUA id file or current cache, ADD the messageid
# of THIS message to the cache, so that replies to it will also be ignored.

# ensure these are blank, not set to something you might have used them for
# previously
REFS=
REFSNL=

:0
* In-Reply-To:.*\/[^    ].*
{
         # Assign the results to REFS
         REFS=${MATCH}
}

:0
* ^References:.*\/[^    ].*
{
         # Append the results to REFS
         # no consideration as to whether REFS was null or not.
         REFS="${REFS} ${MATCH}"
}

# by doing this ONLY if REFS contains non-whitespace, we spare
# ourselves the overhead of the pipe chain invocation when it isn't
# needed (i.e. messages with no references).  Arguably, REFS shouldn't
# be set at all if the headers are empty, but this check is cheap to perform
:0
* REFS ?? [^    ]
{
         REFSNL=`echo "$REFS" | tr -s "  " "\n\n" | \
                 sed -e '/^\([^<].*\|.*[^>]\|\)$/ d'`
}

:0hc:ignore.cache$LOCKEXT
* REFSNL ?? .
* ? grep -qF "$REFSNL" ignore*.cache
| formail -D 131072 ignore.cache

# if the preceeding conditions matched, then file this message
# away as irrelevant.
:0A:
.irrelevant.threads/

####################################################################
# Recipe 2, written by me modifying Recipe 1:

# 20080119
#
# This recipe must ONLY add Message IDs of SURELY irrelevant messages to the
# ignore.cache. Messages submitted to this are surely irrelevant because
# I put them into the irr-training folder

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/bin
MAILDIR=/var/mail/mymail_storage/base
LOGFILE=/var/log/procmail_logs/PROCMAIL.`/bin/date +%Y.%m`.log
LOGABSTRACT = "all"
VERBOSE     = "on"
PMDIR       = "/usr/local/etc/procmail_rc_files"
DEFAULT     = "$MAILDIR/.irrelevant.threads.training/"

:0hc:ignore.cache$LOCKEXT
| formail -D 131072 ignore.cache

.irrelevant.threads.training/



____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>