You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2007/06/18 18:27:25 UTC

svn commit: r548397 - /spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm

Author: jm
Date: Mon Jun 18 09:27:23 2007
New Revision: 548397

URL: http://svn.apache.org/viewvc?view=rev&rev=548397
Log:
bug 5511: fix network lookup timeouts, where lookups were being lost once a timeout was hit; also fix code to match documentation on rbl_timeout's scaling and minimum duration of 1 second; and attempt to collect already-received DNS responses when the timeout is reached. thanks to Mark Martinec

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?view=diff&rev=548397&r1=548396&r2=548397
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Mon Jun 18 09:27:23 2007
@@ -333,11 +333,20 @@
   my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
+  # should not give up before at least attempting to collect some responses
+  # even if previous checks already exceeded rbl_timeout
+  my $notbefore = $now + 1.2;  # at least 1 second from now (time is integer)
+
   my @left = $self->{async}->get_pending_lookups();
   my $total = scalar @left;
 
-  while (($now < $deadline) && !$self->{async}->complete_lookups(1))
+  while ( (($now < $deadline) || ($now < $notbefore)) &&
+          !$self->{async}->complete_lookups(1))
   {
+    dbg(sprintf("dns: harvest_until_rule_completes: on extended time, ".
+                "overdue by %.3f s, still %.3f s",
+        $now-$deadline, $notbefore-$now))  if $now >= $deadline;
+
     if ($self->is_rule_complete($rule)) {
       return 1;
     }
@@ -366,11 +375,21 @@
   my $deadline = $self->{conf}->{rbl_timeout} + $self->{async}->get_last_start_lookup_time();
   my $now = time;
 
+  # should not give up before at least attempting to collect some responses
+  # (which may have arrived by now), even if previous checks (like Razor,
+  # dcc, Botnet, rules) already exceeded rbl_timeout
+  my $notbefore = $now + 1.2;  # at least 1 second from now (time is integer)
+
   my @left = $self->{async}->get_pending_lookups();
   my $total = scalar @left;
 
-  while (($now < $deadline) && !$self->{async}->complete_lookups(1))
+  while ( (($now < $deadline) || ($now < $notbefore)) &&
+          !$self->{async}->complete_lookups(1))
   {
+    dbg(sprintf("dns: harvest_dnsbl_queries: on extended time, ".
+                "overdue by %.3f s, still %.3f s",
+        $now-$deadline, $notbefore-$now))  if $now >= $deadline;
+
     $self->{main}->call_plugins ("check_tick", { permsgstatus => $self });
     @left = $self->{async}->get_pending_lookups();