You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2007/04/12 08:25:51 UTC

svn commit: r527786 - in /spamassassin/trunk: lib/Mail/SpamAssassin/AsyncLoop.pm lib/Mail/SpamAssassin/Dns.pm lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm rules/25_uribl.cf t/config.dist

Author: dos
Date: Wed Apr 11 23:25:50 2007
New Revision: 527786

URL: http://svn.apache.org/viewvc?view=rev&rev=527786
Log:
bug 5384: uridnsbl interaction with skip_rbl_checks in 3.2.0, differing behavior from 3.1.8

 - remove the uridnsbl_timeout option, it wasn't being used ever since the
   M::SA::AsyncLoop code was implemented

 - move the "query_launch_time" from M::SA::Dns into M::SA::AsyncLoop and have
   it set whenever $async->start_lookup is called so that code dealing with DNS
   timeouts isn't scattered all over the place (and via undocumented methods)

 - add a method to M::SA::AsyncLoop to get the start time of the last DNS query
   so that M::SA::Dns can (continue to) take care of timing out DNS queries

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/AsyncLoop.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
    spamassassin/trunk/rules/25_uribl.cf
    spamassassin/trunk/t/config.dist

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/AsyncLoop.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/AsyncLoop.pm?view=diff&rev=527786&r1=527785&r2=527786
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/AsyncLoop.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/AsyncLoop.pm Wed Apr 11 23:25:50 2007
@@ -122,6 +122,7 @@
 
   $self->{queries_started}++;
   $self->{pending_lookups}->{$ent->{key}} = $ent;
+  $self->{last_start_lookup_time} = time;
   $ent;
 }
 
@@ -285,6 +286,7 @@
 
     delete $pending->{$key};
   }
+  delete $self->{last_start_lookup_time};
   $self->{main}->{resolver}->bgabort();
 }
 
@@ -323,6 +325,21 @@
   my ($self, $id) = @_;
   $self->{finished}->{$id} = undef;
 }
+
+# ---------------------------------------------------------------------------
+
+=item $time = $async->get_last_start_lookup_time()
+
+Get the time of the last call to C<start_lookup()>.  If C<start_lookup()> was
+never called or C<abort_remaining_lookups()> has been called
+C<get_last_start_lookup_time()> will return undef.
+
+=cut
+
+sub get_last_start_lookup_time {
+  my ($self) = @_;
+  return $self->{last_start_lookup_time};
+}  
 
 # ---------------------------------------------------------------------------
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?view=diff&rev=527786&r1=527785&r2=527786
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Wed Apr 11 23:25:50 2007
@@ -104,7 +104,6 @@
   # only make a specific query once
   if (!$existing) {
     dbg("dns: launching DNS $type query for $host in background");
-    $self->{query_launch_time} = time;
 
     my $ent = {
       key => $key,
@@ -171,8 +170,6 @@
 
   $ent->{id} = $id;     # tie up the loose end
   $self->{async}->start_lookup($ent);
-
-  $self->{query_launch_time} = time;
 }
 
 ###########################################################################
@@ -331,9 +328,9 @@
 sub harvest_until_rule_completes {
   my ($self, $rule) = @_;
 
-  return if !defined $self->{query_launch_time};
+  return if !defined $self->{async}->get_last_start_lookup_time();
 
-  my $deadline = $self->{conf}->{rbl_timeout} + $self->{query_launch_time};
+  my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
   my @left = $self->{async}->get_pending_lookups();
@@ -351,7 +348,7 @@
     # dynamic timeout
     my $dynamic = (int($self->{conf}->{rbl_timeout}
                       * (1 - (($total - scalar @left) / $total) ** 2) + 0.5)
-                  + $self->{query_launch_time});
+                  + $self->{async}->get_last_start_lookup_time());
     $deadline = $dynamic if ($dynamic < $deadline);
     $now = time;
   }
@@ -360,9 +357,9 @@
 sub harvest_dnsbl_queries {
   my ($self) = @_;
 
-  return if !defined $self->{query_launch_time};
+  return if !defined $self->{async}->get_last_start_lookup_time();
 
-  my $deadline = $self->{conf}->{rbl_timeout} + $self->{query_launch_time};
+  my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
   my @left = $self->{async}->get_pending_lookups();
@@ -376,7 +373,7 @@
     # dynamic timeout
     my $dynamic = (int($self->{conf}->{rbl_timeout}
                       * (1 - (($total - scalar @left) / $total) ** 2) + 0.5)
-                  + $self->{query_launch_time});
+                  + $self->{async}->get_last_start_lookup_time());
     $deadline = $dynamic if ($dynamic < $deadline);
     $now = time;    # and loop again
   }
@@ -393,7 +390,7 @@
     elsif (defined @{$query->{rules}}) {
       $string = join(",", grep defined, @{$query->{rules}});
     }
-    my $delay = time - $self->{query_launch_time};
+    my $delay = time - $self->{async}->get_last_start_lookup_time();
     dbg("dns: timeout for $string after $delay seconds");
   }
 
@@ -422,7 +419,6 @@
 
   $self->set_rbl_tag_data();
 
-  delete $self->{query_launch_time};
   delete $self->{dnscache};
   delete $self->{dnspost};
   delete $self->{dnsuri};

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm?view=diff&rev=527786&r1=527785&r2=527786
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/URIDNSBL.pm Wed Apr 11 23:25:50 2007
@@ -106,18 +106,17 @@
 
 =over 4
 
-=item uridnsbl_timeout N		(default: 2)
-
-Specify the maximum number of seconds to wait for a result before
-giving up on the lookup.  Note that this is in addition to the normal
-DNS timeout applied for DNSBL lookups on IPs found in the Received headers.
-
 =item uridnsbl_max_domains N		(default: 20)
 
 The maximum number of domains to look up.
 
 =back
 
+=head1 NOTES
+
+The C<uridnsbl_timeout> option has been obsoleted by the C<rbl_timeout>
+option.  See the C<Mail::SpamAssassin::Conf> POD for details on C<rbl_timeout>.
+
 =cut
 
 package Mail::SpamAssassin::Plugin::URIDNSBL;
@@ -294,13 +293,6 @@
 sub set_config {
   my($self, $conf) = @_;
   my @cmds = ();
-
-  push(@cmds, {
-    setting => 'uridnsbl_timeout',
-    is_admin => 1,
-    default => 3,
-    type => $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC,
-  });
 
   push(@cmds, {
     setting => 'uridnsbl_max_domains',

Modified: spamassassin/trunk/rules/25_uribl.cf
URL: http://svn.apache.org/viewvc/spamassassin/trunk/rules/25_uribl.cf?view=diff&rev=527786&r1=527785&r2=527786
==============================================================================
--- spamassassin/trunk/rules/25_uribl.cf (original)
+++ spamassassin/trunk/rules/25_uribl.cf Wed Apr 11 23:25:50 2007
@@ -30,10 +30,6 @@
 
 ifplugin Mail::SpamAssassin::Plugin::URIDNSBL
 
-# URI-DNSBL lookups can take a *maximum* of this many seconds past the
-# normal DNSBL lookups.
-uridnsbl_timeout	2
-
 ###########################################################################
 ## SBL
 

Modified: spamassassin/trunk/t/config.dist
URL: http://svn.apache.org/viewvc/spamassassin/trunk/t/config.dist?view=diff&rev=527786&r1=527785&r2=527786
==============================================================================
--- spamassassin/trunk/t/config.dist (original)
+++ spamassassin/trunk/t/config.dist Wed Apr 11 23:25:50 2007
@@ -5,7 +5,7 @@
 # Run network rule tests during 'make test'.
 # test scripts may fail due to network problems)
 
-run_net_tests=n
+run_net_tests=y
 
 # Run DCC Tests
 run_dcc_tests=n