On Tue, 15 Feb 2000 14:41:09 -0600 (CST), Glen Lee Edwards
<GLEdwards(_at_)uswest(_dot_)net> wrote:
On Tue, 15 Feb 2000, Andrew Edelstein wrote:
On Tue, Feb 15, 2000 at 10:18:11AM -0600, Glen Lee Edwards wrote:
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.
If you want concurrent Procmail processes to wait in line for their
turn, a lock is definitely the way to go. But yes, it would probably
be more correct if the list program itself did the locking; that way,
you can call it from the command line, too, without interfering with
whatever Procmail might be doing at the same time. A simple way to
accomplish that is to write a small wrapper which does the locking,
and call the wrapper instead of the real thing. (You can call it by
the same name as the real script, just put it in a directory which is
earlier in your -- and Procmail's -- PATH.)
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.
This should be fairly easy to test. Start a few of'em from the command
line -- perhaps in different xterms -- with full logging and debugging
facilities enabled, if the script has that, and see what happens.
# 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.
I don't see the "separate copy per list match found", is that
something you had cut out? (Do you mean "spawns"?)
: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
}
A few minor comments ...
The ^TO.* pattern is basically always wrong. Either you want ^TO or
you want something else which may or may not involve .* but very
rarely do you need both together. ^TO is a "magical" macro which
contains a (better bounded) wildcard expression in itself. Usually,
you actually want ^TO_ rather than ^TO (if you are running a fairly
recent [like, post-1995] version of Procmail).
So if the address you're trying to match is perl(_at_)something the correct
condition here would probably be ^TO_perl (that's right, no spaces or
wildcards anywhere).
Perhaps you should include the domain part of the address, too,
though. If somebody sends something to you with Cc: perl(_at_)cpan(_dot_)org or
even with Cc: perlers(_at_)example(_dot_)com your recipe will treat that
as an incoming list message as well. (Your current recipe with .*perl
would even match on To: superlative(_at_)yourdomain(_dot_)example(_dot_)net)
^^^^
So I'd recommend ^TO_perl(_at_)christianfamilies(_dot_)net\> for safety.
The Perl lowercase-and-canonicalize thing is pretty neat. If it were
mine, I might still go out of my way to avoid running Perl for a
simple job like this, but I can't come up with something equally
succinct and elegant.
(There's a neat trick for lowercasing matches, by David Tamkin; it
involves matching against a "canonicalized" version of the strings you
expect to match, and use the \/ grab operator to grab the matched
canonicalized string. Don't worry if this description scares you -- I
guess it ought to. :-)
... Best I can come up with off the top of my head is to do it in sed,
but sed's y/// operator is incredibly unwieldy. Or you could lowercase
everything with tr(1) and let the Lhord recognize his own -- to: can
perfectly well be written in lowercase (provided that your listserve
script tolerates that ;^) and if the local part of your list's address
is all lowercase, that shouldn't be a problem either. (The localparts
of addresses are case-significant as per RFC822, while the part after
the @ can always safely be lowercased.)
/* era */
--
Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition