On Tue, 23 Jan 2007, Oscar Retana wrote:
So, I noticed that one (then several) of the "qpsmtpd-forkserver" processes
had been running for almost half an hour. I know the default timeout value is
1200 seconds (20 min), so I changed "timeoutsmtpd" and "timeout" to 300
seconds (5min).
... It doesn't work. I haven't seen in the logs any message about dropping a
connection due to a timeout. Processes are still alive after 30 o 45 min.
Then a found these lines commented out in qpsmtpd/lib/Qpsmtpd/SMTP.pm:
# this is only good for forkserver
# can't set these here, cause forkserver resets them
# $SIG{ALRM} = sub { respond(421, "Game over pal, game over. You got a
# timeout; I just can't wait that long..."); exit };
# $SIG{ALRM} = sub { warn "Connection Timed Out\n"; exit; };
Except from these commented lines, I can't find any other thing handling the
"alarms".
qpsmtpd-forkserver (version 0.31.1) contains:
...
$SIG{ALRM} = sub {
print $client "421 Connection Timed Out\n";
::log(LOGINFO, "Connection Timed Out");
exit; };
...
This code is in the child process before
$qpsmtpd->start_connection(...);$qpsmtpd->run();
is called.
A timeout is set every time a line is read from STDIN via getline():
...
sub getline {
my ($self, $timeout) = @_;
alarm $timeout;
my $line = <STDIN>; # default implementation
alarm 0;
return $line;
}
...
or via Qpsmtpd::TcpServer::read_input():
...
sub read_input {
my $self = shift;
my $timeout =
$self->config('timeoutsmtpd') # qmail smtpd control file
|| $self->config('timeout') # qpsmtpd control file
|| 1200; # default value
alarm $timeout;
while (<STDIN>) {
alarm 0;
$_ =~ s/\r?\n$//s; # advanced chomp
$self->log(LOGDEBUG, "dispatching $_");
$self->connection->notes('original_string', $_);
defined $self->dispatch(split / +/, $_)
or $self->respond(502, "command unrecognized: '$_'");
alarm $timeout;
}
alarm(0);
...