Push enable/disable read call into lib/Qpsmtpd.pm

git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@445 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2005-06-22 18:25:16 +00:00
parent 5853c3a011
commit bc3f52a380
2 changed files with 4 additions and 5 deletions

View File

@ -220,6 +220,7 @@ sub run_hooks {
@r = $self->run_hook($hook, $code, @_);
next unless @r;
if ($r[0] == CONTINUATION) {
$self->disable_read() if $self->isa('Danga::Client');
$self->{_continuation} = [$hook, [@_], @local_hooks];
}
last unless $r[0] == DECLINED;
@ -233,6 +234,7 @@ sub run_hooks {
sub finish_continuation {
my ($self) = @_;
die "No continuation in progress" unless $self->{_continuation};
$self->enable_read() if $self->isa('Danga::Client');
my $todo = $self->{_continuation};
$self->{_continuation} = undef;
my $hook = shift @$todo || die "No hook in the continuation";
@ -242,6 +244,7 @@ sub finish_continuation {
my $code = shift @$todo;
@r = $self->run_hook($hook, $code, @$args);
if ($r[0] == CONTINUATION) {
$self->disable_read() if $self->isa('Danga::Client');
$self->{_continuation} = [$hook, $args, @$todo];
return @r;
}
@ -250,6 +253,7 @@ sub finish_continuation {
$r[0] = DECLINED if not defined $r[0];
my $responder = $hook . "_respond";
if (my $meth = $self->can($responder)) {
warn("continuation finished on $self\n");
return $meth->($self, @r, @$args);
}
die "No ${hook}_respond method";

View File

@ -61,26 +61,21 @@ sub register {
$self->register_hook('connect', 'connect_post_handler');
$self->register_hook('mail', 'mail_handler')
if $self->{_args}->{'defer-reject'};
warn("check_earlytalker registered\n");
1;
}
sub connect_handler {
my ($self, $transaction) = @_;
warn("check early talker");
my $qp = $self->qp;
my $conn = $qp->connection;
$qp->AddTimer($self->{_args}{'wait'}, sub { read_now($qp, $conn) });
$qp->disable_read();
return CONTINUATION;
}
sub read_now {
my ($qp, $conn) = @_;
warn("read now");
$qp->enable_read();
if (my $data = $qp->read(1024)) {
if (length($$data)) {
$qp->log(LOGNOTICE, 'remote host started talking before we said hello');