Don't continually check ->isa() for continue/pause_read - use OO properly

Support case where no connect hook is defined (thus continue_read() never gets called)


git-svn-id: https://svn.perl.org/qpsmtpd/trunk@882 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2008-05-02 17:50:29 +00:00
parent b2532e8daa
commit bb724645a7
2 changed files with 6 additions and 5 deletions

View File

@ -403,11 +403,14 @@ sub run_hooks_no_respond {
return (0, ''); return (0, '');
} }
sub continue_read {} # subclassed in -async
sub pause_read { die "Continuations only work in qpsmtpd-async" }
sub run_continuation { sub run_continuation {
my $self = shift; my $self = shift;
#my $t1 = $SAMPLER->("run_hooks", undef, 1); #my $t1 = $SAMPLER->("run_hooks", undef, 1);
die "No continuation in progress" unless $self->{_continuation}; die "No continuation in progress" unless $self->{_continuation};
$self->continue_read() if $self->isa('Danga::Client'); $self->continue_read();
my $todo = $self->{_continuation}; my $todo = $self->{_continuation};
$self->{_continuation} = undef; $self->{_continuation} = undef;
my $hook = shift @$todo || die "No hook in the continuation"; my $hook = shift @$todo || die "No hook in the continuation";
@ -441,7 +444,7 @@ sub run_continuation {
} }
if ($r[0] == YIELD) { if ($r[0] == YIELD) {
$self->pause_read() if $self->isa('Danga::Client'); $self->pause_read();
$self->{_continuation} = [$hook, $args, @$todo]; $self->{_continuation} = [$hook, $args, @$todo];
return @r; return @r;
} }

View File

@ -1,5 +1,3 @@
# $Id: Server.pm,v 1.10 2005/02/14 22:04:48 msergeant Exp $
package Qpsmtpd::PollServer; package Qpsmtpd::PollServer;
use base ('Danga::Client', 'Qpsmtpd::SMTP'); use base ('Danga::Client', 'Qpsmtpd::SMTP');
@ -160,7 +158,7 @@ sub start_conversation {
$conn->remote_info("[$ip]"); $conn->remote_info("[$ip]");
ParaDNS->new( ParaDNS->new(
finished => sub { $self->run_hooks("connect") }, finished => sub { $self->continue_read(); $self->run_hooks("connect") },
# NB: Setting remote_info to the same as remote_host # NB: Setting remote_info to the same as remote_host
callback => sub { $conn->remote_info($conn->remote_host($_[0])) }, callback => sub { $conn->remote_info($conn->remote_host($_[0])) },
host => $ip, host => $ip,