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 2004/10/04 00:07:19 UTC

svn commit: rev 51854 - spamassassin/trunk/lib/Mail/SpamAssassin

Author: jm
Date: Sun Oct  3 15:07:19 2004
New Revision: 51854

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
Log:
bug 3794: add an eval { } block around harvest_dnsbl_results() core loop to trap die()s thrown from Net::DNS, instead of propogating to user code

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Dns.pm	Sun Oct  3 15:07:19 2004
@@ -292,30 +292,41 @@
   @waiting = grep { defined $_->[BGSOCK] } @waiting;
   $total = scalar @waiting;
 
-  while (@waiting) {
-    @left = ();
-    for my $query (@waiting) {
-      if ($self->{res}->bgisready($query->[BGSOCK])) {
-	$self->process_dnsbl_result($query);
+  # trap this loop in an eval { } block, as Net::DNS could throw
+  # die()s our way; in particular, process_dnsbl_results() has
+  # thrown die()s before (bug 3794).
+  eval {
+    while (@waiting) {
+      @left = ();
+      for my $query (@waiting) {
+        if ($self->{res}->bgisready($query->[BGSOCK])) {
+          $self->process_dnsbl_result($query);
+        }
+        else {
+          push(@left, $query);
+        }
       }
-      else {
-	push(@left, $query);
-      }
-    }
 
-    $self->{main}->call_plugins ("check_tick", { permsgstatus => $self });
+      $self->{main}->call_plugins ("check_tick", { permsgstatus => $self });
 
-    last unless @left;
-    last if time >= $timeout;
-    @waiting = @left;
-    # dynamic timeout
-    my $dynamic = (int($self->{conf}->{rbl_timeout}
-		       * (1 - (($total - @left) / $total) ** 2) + 0.5)
-		   + $self->{rbl_launch});
-    $timeout = $dynamic if ($dynamic < $timeout);
-    sleep 1;
+      last unless @left;
+      last if time >= $timeout;
+      @waiting = @left;
+      # dynamic timeout
+      my $dynamic = (int($self->{conf}->{rbl_timeout}
+                        * (1 - (($total - @left) / $total) ** 2) + 0.5)
+                    + $self->{rbl_launch});
+      $timeout = $dynamic if ($dynamic < $timeout);
+      sleep 1;
+    }
+    dbg("dns: success for " . ($total - @left) . " of $total queries");
+  };
+
+  if ($@) {
+    dbg("dns: DNS harvest failed: $@");
+    # carry on and clean up the BGSOCKs anyway.
   }
-  dbg("dns: success for " . ($total - @left) . " of $total queries");
+
   # timeouts
   for my $query (@left) {
     my $string = '';