From e1982f05d413118dbc47a64718919e03aa1f1743 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Mon, 28 Nov 2005 19:07:56 +0000 Subject: [PATCH] Fixed to use same subsystem as dnsbl plugin git-svn-id: https://svn.perl.org/qpsmtpd/trunk@581 958fd67b-6ff1-0310-b445-bb7760255be9 --- plugins/require_resolvable_fromhost | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/plugins/require_resolvable_fromhost b/plugins/require_resolvable_fromhost index a587bb5..a7a498f 100644 --- a/plugins/require_resolvable_fromhost +++ b/plugins/require_resolvable_fromhost @@ -28,11 +28,12 @@ sub check_dns { return DECLINED; } - $self->transaction->notes('pending_dns_queries', 2); + my $total_queries = 2; my $qp = $self->qp; $self->log(LOGDEBUG, "Checking $host for MX record in the background"); Danga::DNS->new( callback => sub { dns_result($qp, @_) }, + finished => sub { $total_queries--; finished($qp, $total_queries) }, host => $host, type => "MX", client => $qp->input_sock, @@ -40,19 +41,21 @@ sub check_dns { $self->log(LOGDEBUG, "Checking $host for A record in the background"); Danga::DNS->new( callback => sub { dns_result($qp, @_) }, + finished => sub { $total_queries--; finished($qp, $total_queries) }, host => $host, client => $qp->input_sock, ); return CONTINUATION; } +sub finished { + my ($qp, $total_zones) = @_; + $qp->finish_continuation unless $total_zones; +} sub dns_result { my ($qp, $result, $query) = @_; - my $pending = $qp->transaction->notes('pending_dns_queries'); - $qp->transaction->notes('pending_dns_queries', --$pending); - if ($result =~ /^[A-Z]+$/) { # probably an error $qp->log(LOGDEBUG, "DNS error: $result looking up $query"); @@ -60,8 +63,6 @@ sub dns_result { $qp->transaction->notes('resolvable', 1); $qp->log(LOGDEBUG, "DNS lookup $query returned: $result"); } - - $qp->finish_continuation unless $pending; }