procmail
[Top] [All Lists]

Re: Locking

2001-04-21 22:08:08
On 21 Apr, Paul M Foster wrote:
| I've been using procmail under Linux for a while, but I don't really
| understand locking. The man page and most FAQs presume a prior knowledge
| of why locking is important and the types of locking necessary. I don't
| have that prior knowledge. A couple of other possibly related issues
| puzzle me as well. In particular:
| 
| 0. Why are lockfiles needed at all?

To (hopefully) prevent multiple processes from writing to the same
file at the same time, clobbering or mangling each others' output while
doing so.

| 1. Apparently, when piping through, say, formail, you don't need to use
| a lockfile. Why? (Of course, I don't know why you'd use a lockfile in
| the first place.)

A pipe to to formail isn't writing to any regular files on disk.
 
| 2. Under certain circumstances, you would use the "f" flag in the
| beginning of a recipe to indicate that you want procmail to filter the
| header or whatever. But if I use a piping recipe (e.g. | formail ...),
| why would I need to _tell_ procmail I'm filtering the email, since the
| pipe automatically indicates some sort of filter? Perhaps more
| important, how does procmail handle things internally differently if you
| tell it to filter, versus when you don't?

Because your assumption that a pipe automatically indicates a filter is
incorrect.

  :0:
  * spam condition(s)
  | gzip -c >>$SPAM.gz

This is a delivery not a filter. ;-)
 
| 3. Apparently, when you send mail to a directory, you don't need a
| lockfile. Why?

Pass. (I don't write to directories, but my guess is you're writing to
unique files as opposed to the same regular file.)

| 4. When sending to a folder/file, you need a lockfile. If I've run
| fetchmail, and fetchmail is delivering via procmail, there's only one
| process accessing my mail folders. If only one process is accessing
| them, why would a lockfile be needed? I've always assumed that lockfiles
| were needed only if you expected more than one process/user to access a
| file at the same time.

Because there's no reason to take a chance with mail. I don't do
fetchmail, so it's only a guess, but it wouldn't surprise me if it
handled delivery of multiple messages asynchronously. But even if
that's wrong, doesn't your system generate any local mail?  Cron job
output, log rotation, any other administrative stuff?  Even if you can
say no to that, it goes back to the first sentence this paragraph -
because there's no good reason not to.



_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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