Make number of accepts we perform lower if MAXCONNIP is used

Make connection hook get called after we do all the accept()s


git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@420 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2005-05-17 11:48:02 +00:00
parent e3a5d6c3c6
commit 62aebd2a3e
3 changed files with 19 additions and 10 deletions

View File

@ -77,7 +77,6 @@ our (
);
%OtherFds = ();
$LocalPostLoopCallback = 0;
#####################################################################
### C L A S S M E T H O D S

View File

@ -47,6 +47,7 @@ sub new {
$self = fields::new($self) unless ref $self;
$self->SUPER::new( @_ );
$self->{start_time} = time;
$self->{mode} = 'connect';
$self->load_plugins;
return $self;
}
@ -112,7 +113,16 @@ sub _process_line {
my $self = shift;
my $line = shift;
if ($self->{mode} eq 'cmd') {
if ($self->{mode} eq 'connect') {
warn("Connection incoming\n");
my $rc = $self->start_conversation;
if ($rc != DONE) {
$self->close;
return;
}
$self->{mode} = 'cmd';
}
elsif ($self->{mode} eq 'cmd') {
$line =~ s/\r?\n//;
return $self->process_cmd($line);
}

14
qpsmtpd
View File

@ -289,10 +289,14 @@ sub config_handler {
return;
}
# TODO:
# - Make number of accepts() we do dependant on whether MAXCONNIP is set
# Accept all new connections
sub accept_handler {
for (1..10000) {
last unless _accept_handler();
my $max = $MAXCONNIP ? 100 : 1000;
for (1 .. $max) {
last if ! _accept_handler();
}
}
@ -359,11 +363,7 @@ sub _accept_handler {
$client->log(LOGINFO, "accepted connection $running/$MAXCONN ($num_conn/$MAXCONNIP) from $rem_ip");
}
my $rc = $client->start_conversation;
if ($rc != DONE) {
$client->close;
return 1;
}
$client->push_back_read("Connect\n");
$client->watch_read(1);
return 1;
}