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 2006/04/04 14:23:28 UTC

svn commit: r391287 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Conf.pm Dns.pm

Author: jm
Date: Tue Apr  4 05:23:25 2006
New Revision: 391287

URL: http://svn.apache.org/viewcvs?rev=391287&view=rev
Log:
bug 4767: all net checks will stop forever if is_dns_available() encounters a single failure; add 'dns_test_interval' instead to auto-retest every 10 minutes, patch from Dallas Engelken <dallase /at/ nmgi.com>

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

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=391287&r1=391286&r2=391287&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Tue Apr  4 05:23:25 2006
@@ -1114,6 +1114,23 @@
     }
   });
 
+=item dns_test_interval n   (default: 600 seconds)
+
+If dns_available is set to 'test' (which is the default), the dns_test_interval
+time in number of seconds will tell SpamAssassin how often to retest for working DNS.
+
+=cut
+
+  push (@cmds, {
+    setting => 'dns_test_interval',
+    default => 600,
+    code => sub {
+      my ($self, $key, $value, $line) = @_;
+      if ($value !~ /^\d+$/) { return $INVALID_VALUE; }
+      $self->{dns_test_interval} = $value;
+    }
+  });
+
 =back
 
 =head2 LEARNING OPTIONS

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?rev=391287&r1=391286&r2=391287&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Tue Apr  4 05:23:25 2006
@@ -33,7 +33,7 @@
 use Carp;
 
 use vars qw{
-  $KNOWN_BAD_DIALUP_RANGES @EXISTING_DOMAINS $IS_DNS_AVAILABLE $VERSION
+  $KNOWN_BAD_DIALUP_RANGES @EXISTING_DOMAINS $IS_DNS_AVAILABLE $LAST_DNS_CHECK $VERSION
 };
 
 # use very well-connected domains (fast DNS response, many DNS servers,
@@ -556,8 +556,20 @@
 sub is_dns_available {
   my ($self) = @_;
   my $dnsopt = $self->{conf}->{dns_available};
+  my $dnsint = $self->{conf}->{dns_test_interval} || 600;
   my @domains;
 
+  $LAST_DNS_CHECK ||= 0;
+  my $diff = time() - $LAST_DNS_CHECK;
+
+  # undef $IS_DNS_AVAILABLE if we should be testing for
+  # working DNS and our check interval time has passed
+  dbg("dns: dnsopt=$dnsopt dnsint=$dnsint diff=$diff");
+  $IS_DNS_AVAILABLE=undef if ($dnsopt eq "test" && $diff > $dnsint);
+
+  dbg("dns: is_dns_available() last checked $diff seconds ago; dns available=".
+            ($IS_DNS_AVAILABLE ? $IS_DNS_AVAILABLE : "(undef)"));
+
   return $IS_DNS_AVAILABLE if (defined $IS_DNS_AVAILABLE);
 
   $IS_DNS_AVAILABLE = 0;
@@ -611,6 +623,7 @@
   # but only uses the first in a background query like we use.
   # Try the different nameservers here in case the first one is not woorking
   
+  $LAST_DNS_CHECK = time();
   my @nameservers = $self->{resolver}->nameservers();
   dbg("dns: testing resolver nameservers: ".join(", ", @nameservers));
   my $ns;