On Sat, Jun 09, 2001 at 01:54:37PM -0600, Charles Cazabon wrote:
 
> Perhaps something like a "maxlifetime" control file for qmail-remote and
> qmail-smtpd?  At process startup, set an alarm for X seconds -- if the ALRM is
> received, abort the connection as gracefully as possible (i.e. try to send
> RSET and QUIT in qmail-remote, issue a 4xx error in qmail-smtpd) but quit
> regardless of whether these attempts to quit gracefully are successful or not.
> 
> It doesn't sound too complicated.  Anybody see any major issues with this?

No, but this may be more complicated than needed.
I've been using the attached program on one of my machines for years 
(the machine was behind a dialup line and it was definitively not
funny to sponsor the Deutsche Telekom just because the other end
of a SMTP connection was slow).
It worked in it's crude form. It leaves a hole open which could
lead to duplicate transfers.

Regards, Uwe
---------- setalarm.c -----------
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
static void die_usage(void)
{fputs("usage: setalarm SECONDS program [arguments ...]\n",stderr);
 exit(111);}
static void die_parse(void)
{fputs("setalarm: fatal: failed to parse the number of seconds\n",stderr);
 exit(111);}
static void die_exec(char *x)
{int e=errno;
 fputs("setalarm: fatal: failed to execute ",stderr);
 perror(x);
 exit(111);}

int 
main(int argc, char **argv)
{
        unsigned long ul;
        int e;
        char *ep;
        ssize_t l;
        if (argc<3) die_parse();
        errno=0;
        ul=strtoul(argv[1],&ep,10);
        if (*ep || !argv[1][0] || errno==ERANGE) die_parse();
        signal(SIGALRM,SIG_DFL);
        alarm(ul);
        execvp(argv[2],argv+2);
        die_exec(argv[2]);
}

Reply via email to