You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2018/10/05 14:22:41 UTC

svn commit: r1842923 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Constants.pm Dns.pm Plugin/Check.pm

Author: hege
Date: Fri Oct  5 14:22:40 2018
New Revision: 1842923

URL: http://svn.apache.org/viewvc?rev=1842923&view=rev
Log:
Clean up DNS handling, remove pointless HARVEST_DNSBL_PRIORITY

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm?rev=1842923&r1=1842922&r2=1842923&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Constants.pm Fri Oct  5 14:22:40 2018
@@ -40,7 +40,7 @@ BEGIN {
   );
   # These are generic constants that may be used across several modules
   @SA_VARS = qw(
-	HARVEST_DNSBL_PRIORITY MBX_SEPARATOR
+	MBX_SEPARATOR
 	MAX_BODY_LINE_LENGTH MAX_HEADER_KEY_LENGTH MAX_HEADER_VALUE_LENGTH
 	MAX_HEADER_LENGTH ARITH_EXPRESSION_LEXER AI_TIME_UNKNOWN
 	CHARSETS_LIKELY_TO_FP_AS_CAPS MAX_URI_LENGTH
@@ -347,8 +347,6 @@ use constant IP_ADDRESS => qr/
 
 # ---------------------------------------------------------------------------
 
-use constant HARVEST_DNSBL_PRIORITY =>  500;
-
 # regular expression that matches message separators in The University of
 # Washington's MBX mailbox format
 use constant MBX_SEPARATOR => qr/^([\s\d]\d-[a-zA-Z]{3}-\d{4}\s\d{2}:\d{2}:\d{2}.*),(\d+);([\da-f]{12})-(\w{8})\r?$/;

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm?rev=1842923&r1=1842922&r2=1842923&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm Fri Oct  5 14:22:40 2018
@@ -413,7 +413,7 @@ sub harvest_dnsbl_queries {
     my ($alldone,$anydone) =
       $self->{async}->complete_lookups($first ? 0 : 1.0,  1);
 
-    last  if $alldone;
+    last  if $alldone || $self->{deadline_exceeded};
 
     dbg("dns: harvest_dnsbl_queries - check_tick");
     $self->{main}->call_plugins ("check_tick", { permsgstatus => $self });

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm?rev=1842923&r1=1842922&r2=1842923&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Check.pm Fri Oct  5 14:22:40 2018
@@ -79,7 +79,7 @@ sub check_main {
   # rbl calls.
   $pms->extract_message_metadata();
 
-  my $needs_dnsbl_harvest_p = 1; # harvest needs to be run
+  my $do_dns = $pms->is_dns_available();
   my $rbls_running = 0;
 
   my $decoded = $pms->get_decoded_stripped_body_text_array();
@@ -92,7 +92,7 @@ sub check_main {
   my @uris = $pms->get_uri_list();
 
   # Make sure priority -100 exists for launching DNS
-  $pms->{conf}->{priorities}->{-100} ||= 1;
+  $pms->{conf}->{priorities}->{-100} ||= 1 if $do_dns;
 
   foreach my $priority (sort { $a <=> $b } keys %{$pms->{conf}->{priorities}}) {
     # no need to run if there are no priorities at this level.  This can
@@ -115,7 +115,7 @@ sub check_main {
     # inspect the message.  We try to launch all DNS queries at priority
     # -100, so one can shortcircuit tests at lower priority and not launch
     # unneeded DNS queries.
-    if (!$rbls_running && $priority >= -100) {
+    if ($do_dns && !$rbls_running && $priority >= -100) {
       $rbls_running = 1;
       $pms->{async}->{wait_launch} = 0; # permission granted
       $pms->{async}->launch_queue(); # check if something was queued
@@ -125,26 +125,6 @@ sub check_main {
     my $timer = $self->{main}->time_method("tests_pri_".$priority);
     dbg("check: running tests for priority: $priority");
 
-    # only harvest the dnsbl queries once priority HARVEST_DNSBL_PRIORITY
-    # has been reached and then only run once
-    #
-    # TODO: is this block still needed here? is HARVEST_DNSBL_PRIORITY used?
-    #
-    if ($priority >= HARVEST_DNSBL_PRIORITY
-        && $needs_dnsbl_harvest_p
-        && !$self->{main}->call_plugins("have_shortcircuited",
-                                        { permsgstatus => $pms }))
-    {
-      # harvest the DNS results
-      $pms->harvest_dnsbl_queries();
-      $needs_dnsbl_harvest_p = 0;
-
-      # finish the DNS results
-      $pms->rbl_finish();
-      $self->{main}->call_plugins("check_post_dnsbl", { permsgstatus => $pms });
-      $pms->{resolver}->finish_socket() if $pms->{resolver};
-    }
-
     $pms->harvest_completed_queries() if $rbls_running;
     # allow other, plugin-defined rule types to be called here
     $self->{main}->call_plugins ("check_rules_at_priority",
@@ -198,17 +178,14 @@ sub check_main {
     last if $pms->{deadline_exceeded};
   }
 
-  # sanity check, it is possible that no rules >= HARVEST_DNSBL_PRIORITY ran so the harvest
-  # may not have run yet.  Check, and if so, go ahead and harvest here.
-  if ($needs_dnsbl_harvest_p) {
+  # Finish DNS results
+  if ($do_dns) {
     if (!$self->{main}->call_plugins("have_shortcircuited",
                                         { permsgstatus => $pms }))
     {
-      # harvest the DNS results
       $pms->harvest_dnsbl_queries();
     }
 
-    # finish the DNS results
     $pms->rbl_finish();
     $self->{main}->call_plugins ("check_post_dnsbl", { permsgstatus => $pms });
     $pms->{resolver}->finish_socket() if $pms->{resolver};
@@ -283,12 +260,6 @@ sub run_rbl_eval_tests {
   my ($self, $pms) = @_;
   my ($rulename, $pat, @args);
 
-  # XXX - possible speed up, moving this check out of the subroutine into Check->new()
-  if ($self->{main}->{local_tests_only}) {
-    dbg("rules: local tests only, ignoring RBL eval");
-    return 0;
-  }
-
   while (my ($rulename, $test) = each %{$pms->{conf}->{rbl_evals}}) {
     my $score = $pms->{conf}->{scores}->{$rulename};
     next unless $score;