procmail
[Top] [All Lists]

Re: scope of locking (tiglet)

1997-04-10 14:52:00
Bill Evans asked,

| Suppose I have a recipe of the form
| 
|   :0HBiw:$SGHOMEU/eeyore.lock
|   * ? $SGHOMEX/eeyore.pl
|   /dev/null
| 
| where eeyore.pl is a program which has lots of side effects and which
| must run single-threaded, so I want eeyore.lock to be active during
| the testing part of the recipe.  I have three questions.
| 
| 1.  Does the lock take effect only during the action line of the
|     recipe, or is it active during the testing parts as well?

No, only during the action.  Run it with VERBOSE=on and you'll see that
in your logfile.  It has to be this way: otherwise procmail would lock 
every mailbox it *doesn't* save to and local lockfiles would be pointless;
we'd all use one global lockfile for all our mail (and cloning would
be next to impossible).

| 3.  Has the answer to question 1 changed in recent versions of
|     procmail?

No.

I did post a way to get a lock on an exit code condition; maybe the person
who poo-pooed it at the time doesn't think it's so silly any more.  If he
still does, well, he has spoken his piece and doesn't need to repeat it.

Since there no unlocked conditions, and we need to do the test and the lock
for every piece of mail where procmail passes through this part of your
rcfile, the logic is a little simpler than the example I gave then:
  
  OLDLOCKFILE
  :0
  * LOCKFILE ?? .
  { OLDLOCKFILE=$LOCKFILE }

  LOCKFILE=$SGHOMEU/eeyore.lock

    :0HB # no need for `i' or `w' on a save to /dev/null
    * ? $SGHOMEX/eeyore.pl
    /dev/null

  :0
  * OLDLOCKFILE ?? .
  { LOCKFILE=$OLDLOCKFILE }
  :0E
  { LOCKFILE }

  OLDLOCKFILE

If you know that there will be never be a global or regional lockfile in
effect at that point in your rcfile, it becomes simpler yet:

  LOCKFILE=$SGHOMEU/eeyore.lock

    :0HB
    * ? $SGHOMEX/eeyore.pl
    /dev/null

  LOCKFILE

But here's a thought: does $SGHOMEX/eeyore.pl write to stdout?  If not,
we can simplify it greatly by putting the perl call into the action line
as we do with formail -D:

     :0W:$SGHOMEU/eeyore.lock
     | $SGHOMEX/eeyore.pl

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