Re: [Exim] Delivering one mail at a time

Top Page
Delete this message
Reply to this message
Author: Sheldon Hearn
Date:  
To: Ceri
CC: exim-users
Subject: Re: [Exim] Delivering one mail at a time

On Wed, 20 Mar 2002 16:49:45 GMT, Ceri wrote:

> I have a *very* slow program that I pipe mails for a certain local user
> to, which will end up rejecting any mails after 10 attempts to lock the
> files it's writing to (as another instance of the program is still
> delivering an earlier mail).


If speed isn't too much of an issue, just write a shell wrapper for the
program that makes use of FreeBSD lockf(1) as follows:

#!/bin/sh
#
lockf -ks /path/to/.tmp/slowprog.lock /path/to/slowprog

Create /path/to/slowprog.lock beforehand and make sure it's
appropriately owned. This ensures that you're not at risk of a DoS
where someone creates the slowprog.lock and locks it indefinitely. Of
course, if you use a directory that nobody else has write access to,
you'll also be okay, but best play it safe.

This simple wrapper will effectively ensure that only one instance of
slowprog is ever run at once (provided its only ever run through the
wrapper).

It doesn't solve the problem of having a potentially large number of
Exim procresses all waiting around for their instance of the wrapper to
grab the lock on slowprog.lock. :-)

Of course, this assumes (because I've seen you active on the FreeBSD
mailing lists) that you're trying this on a FreeBSD system. The
lockf(1) program is non-standard and may not exist (or may provide a
different interface) on other platforms.

Ciao,
Sheldon.