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:
parent
e3a5d6c3c6
commit
62aebd2a3e
@ -77,7 +77,6 @@ our (
|
|||||||
);
|
);
|
||||||
|
|
||||||
%OtherFds = ();
|
%OtherFds = ();
|
||||||
$LocalPostLoopCallback = 0;
|
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
### C L A S S M E T H O D S
|
### C L A S S M E T H O D S
|
||||||
|
@ -47,6 +47,7 @@ sub new {
|
|||||||
$self = fields::new($self) unless ref $self;
|
$self = fields::new($self) unless ref $self;
|
||||||
$self->SUPER::new( @_ );
|
$self->SUPER::new( @_ );
|
||||||
$self->{start_time} = time;
|
$self->{start_time} = time;
|
||||||
|
$self->{mode} = 'connect';
|
||||||
$self->load_plugins;
|
$self->load_plugins;
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
@ -112,7 +113,16 @@ sub _process_line {
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $line = 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//;
|
$line =~ s/\r?\n//;
|
||||||
return $self->process_cmd($line);
|
return $self->process_cmd($line);
|
||||||
}
|
}
|
||||||
|
14
qpsmtpd
14
qpsmtpd
@ -289,10 +289,14 @@ sub config_handler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO:
|
||||||
|
# - Make number of accepts() we do dependant on whether MAXCONNIP is set
|
||||||
|
|
||||||
# Accept all new connections
|
# Accept all new connections
|
||||||
sub accept_handler {
|
sub accept_handler {
|
||||||
for (1..10000) {
|
my $max = $MAXCONNIP ? 100 : 1000;
|
||||||
last unless _accept_handler();
|
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");
|
$client->log(LOGINFO, "accepted connection $running/$MAXCONN ($num_conn/$MAXCONNIP) from $rem_ip");
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rc = $client->start_conversation;
|
$client->push_back_read("Connect\n");
|
||||||
if ($rc != DONE) {
|
|
||||||
$client->close;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
$client->watch_read(1);
|
$client->watch_read(1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user