Author: radu
Date: Wed Apr 30 23:18:46 2008
New Revision: 880
Modified:
trunk/plugins/async/require_resolvable_fromhost
Log:
Follow the logic of the non-async version and other MTAs: make first
the MX lookups and, only if they return nothing, make the A lookups.
Modified: trunk/plugins/async/require_resolvable_fromhost
==============================================================================
--- trunk/plugins/async/require_resolvable_fromhost (original)
+++ trunk/plugins/async/require_resolvable_fromhost Wed Apr 30 23:18:46 2008
@@ -73,7 +73,8 @@
$qp->input_sock->pause_read;
my $a_records = [];
- my $num_queries = $has_ipv6 ? 3 : 2; # queries in progress
+ my $num_queries = 1; # queries in progress
+ my $mx_found = 0;
ParaDNS->new(
callback => sub {
@@ -81,6 +82,7 @@
return if $mx =~ /^[A-Z]+$/; # error
my $addr = $mx->[0];
+ $mx_found = 1;
$num_queries++;
ParaDNS->new(
@@ -100,28 +102,42 @@
);
}
},
- finished => sub { $num_queries--; $self->finish_up($qp, $a_records,
$num_queries) },
+ finished => sub {
+
+ unless ($mx_found) {
+
+ $num_queries++;
+ ParaDNS->new(
+ callback => sub { push @$a_records, $_[0] if $_[0] !~
/^[A-Z]+$/; },
+ finished => sub { $num_queries--; $self->finish_up($qp,
$a_records, $num_queries) },
+ host => $host,
+ type => 'A',
+ );
+
+ if ($has_ipv6) {
+ $num_queries++;
+ ParaDNS->new(
+ callback => sub { push @$a_records, $_[0] if $_[0] !~
/^[A-Z]+$/; },
+ finished => sub { $num_queries--;
$self->finish_up($qp, $a_records, $num_queries) },
+ host => $host,
+ type => 'AAAA',
+ );
+ }
+
+ }
+
+ $num_queries--;
+ $self->finish_up($qp, $a_records, $num_queries);
+ },
host => $host,
type => 'MX',
- ) or return;
- ParaDNS->new(
- callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
- finished => sub { $num_queries--; $self->finish_up($qp, $a_records,
$num_queries) },
- host => $host,
- type => 'A',
- ) or return;
- ParaDNS->new(
- callback => sub { push @$a_records, $_[0] if $_[0] !~ /^[A-Z]+$/; },
- finished => sub { $num_queries--; $self->finish_up($qp, $a_records,
$num_queries) },
- host => $host,
- type => 'AAAA',
- ) or return if $has_ipv6;
+ ) or $qp->input_sock->continue_read, return;
return 1;
}
sub finish_up {
- my ($self, $qp, $a_records, $num_queries, $source) = @_;
+ my ($self, $qp, $a_records, $num_queries) = @_;
return if defined $qp->transaction->notes('resolvable_fromhost');