procmail
[Top] [All Lists]

Re: lock files

2000-02-15 13:40:15
On Tue, 15 Feb 2000, Andrew Edelstein wrote:

On Tue, Feb 15, 2000 at 10:18:11AM -0600, Glen Lee Edwards wrote:
ABSOLUTELY!  I wrote a talk list program in Perl that I use on a couple
of my domains.  I use procmail to read TO, and then forward the letter to
the program if the letter is addressed to one of the talk lists.  I've had 
trouble with letters dying if the talk list program is still dealing with 
a previous letter while another tries to access the program.  If I'm reading
your letter correctly if I have :0: any subsequent letters to the list
program will remain in a holding pattern until the lock is released.

That's probably not what you want actually. What you want is :0 w or :0 W.
This will cause procmail to let the program finish before continuing. Placing
a lock file probably won't prevent it from runnng another instance of your
perl script. Another option is to add some sort of locking inside the script,
so one invocation doesn't stomp on another when they both try to write to the
same destination file.

Andrew,

The main problem I've had is with mail waiting to access the listserve
script being dropped in the Inbox for a reason that isn't clear to me.

listserve.cgi is not being run as a daemon.  I had assumed that as soon as
one copy was started, even if it didn't finish execution Linux had the
ability to execute another.  In this case, say total program execution
takes 5 seconds, and during that time 4 more letters hit the list, there
should be up to 5 copies of the program running at one time.  I don't know
the reason why some letters don't start the program executing - I'm
assuming that it's because the server is only allowing one copy of
listserve.cgi to execute at a time.  I may be wrong.

Based on the above premise, I've rewritten the program to fork immediately
upon execution and for the parent to shut down.  I'm using the following
recipe in .procmailrc to try to hold new letters for listserve.cgi until
procmail determines that it's now available:

*****************
# The following code checks for list id, moves Cc addresses to the To: field,
# spans a separate copy per list match found so letters can be cross
# posted, and lowercases list_id for file access match; then sends the
# letter to the listserve program.

<cut>

# perl(_at_)christianfamilies(_dot_)net talk list recipe

:0 c
* ^TO.*perl
{  
  :0 fwh
  | perl -pe 's/(^To|^Cc)(.*)(perl.*?net)(.*)/To: \L$3\E/i;'

  :0 aw: listserve.lock
  | /deleted/path/to/listserve.cgi    
}

<cut>

*****************

The above seems to have worked, so either I'm correct in my analysis of
the problem, or in my futility I've stumbled across a solution to the real
problem.

Your comments are welcome.

Glen

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