Get alarm/timeout from a param

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@593 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2005-12-30 19:46:33 +00:00
parent abcdd3212c
commit 67a6787625

View File

@ -14,6 +14,7 @@ use fields qw(
max_size max_size
hooks hooks
start_time start_time
cmd_timeout
_auth _auth
_auth_user _auth_user
_auth_mechanism _auth_mechanism
@ -49,6 +50,7 @@ sub new {
$self = fields::new($self) unless ref $self; $self = fields::new($self) unless ref $self;
$self->SUPER::new( @_ ); $self->SUPER::new( @_ );
$self->{cmd_timeout} = 5;
$self->{start_time} = time; $self->{start_time} = time;
$self->{mode} = 'connect'; $self->{mode} = 'connect';
$self->load_plugins; $self->load_plugins;
@ -106,7 +108,7 @@ sub process_line {
my ($pkg, $file, $line) = caller(); my ($pkg, $file, $line) = caller();
die "ALARM: ($self->{mode}) $pkg, $file, $line"; die "ALARM: ($self->{mode}) $pkg, $file, $line";
}; };
my $prev = alarm(2); # must process a command in < 2 seconds my $prev = alarm($self->{cmd_timeout}); # must process a command in < N seconds
eval { $self->_process_line($line) }; eval { $self->_process_line($line) };
alarm($prev); alarm($prev);
if ($@) { if ($@) {