diff --git a/lib/Danga/Socket.pm b/lib/Danga/Socket.pm index 95c9c2e..f91a974 100644 --- a/lib/Danga/Socket.pm +++ b/lib/Danga/Socket.pm @@ -77,7 +77,6 @@ our ( ); %OtherFds = (); -$LocalPostLoopCallback = 0; ##################################################################### ### C L A S S M E T H O D S diff --git a/lib/Qpsmtpd/PollServer.pm b/lib/Qpsmtpd/PollServer.pm index 5e14362..f88d690 100644 --- a/lib/Qpsmtpd/PollServer.pm +++ b/lib/Qpsmtpd/PollServer.pm @@ -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; } @@ -111,8 +112,17 @@ sub process_line { 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); } diff --git a/qpsmtpd b/qpsmtpd index 7b9f989..f69467d 100755 --- a/qpsmtpd +++ b/qpsmtpd @@ -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; }