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/12/30 22:04:39 UTC

svn commit: r607589 - /spamassassin/branches/3.2/sa-update.raw

Author: jm
Date: Sun Dec 30 13:04:39 2007
New Revision: 607589

URL: http://svn.apache.org/viewvc?rev=607589&view=rev
Log:
bug 5715: allow for more than one sa-update MIRRORED.BY file host in DNS, for redundancy

Modified:
    spamassassin/branches/3.2/sa-update.raw

Modified: spamassassin/branches/3.2/sa-update.raw
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.2/sa-update.raw?rev=607589&r1=607588&r2=607589&view=diff
==============================================================================
--- spamassassin/branches/3.2/sa-update.raw (original)
+++ spamassassin/branches/3.2/sa-update.raw Sun Dec 30 13:04:39 2007
@@ -415,7 +415,7 @@
   my $DNSQ = "$RevSAVersion.$channel";
 
   my $newV;
-  my $dnsV = do_txt_query($DNSQ);
+  my $dnsV = join(' ', do_txt_query($DNSQ));
   if (defined $dnsV && $dnsV =~ /^(\d+)/) {
     $newV = $1 if (!defined $newV || $1 > $newV);
     dbg("dns: $DNSQ => $dnsV, parsed as $1");
@@ -477,12 +477,20 @@
   else {
     # We don't currently have the list of mirrors, so go grab it.
     dbg("channel: no MIRRORED.BY file available");
-    my $mirror = do_txt_query("mirrors.$channel");
-    unless ($mirror) {
+    my @mirrors = do_txt_query("mirrors.$channel");
+    unless (@mirrors) {
       warn "error: no mirror data available for channel $channel\n";
       channel_failed("channel: MIRRORED.BY file location was not in DNS");
+      next;
+    }
+    foreach my $mirror (@mirrors) {
+      $mirby = http_get($mirror);
+      unless ($mirby) {
+        dbg("channel: no mirror data available for channel $channel from $mirror");
+        next;
+      }
+      last;
     }
-    $mirby = http_get($mirror);
     unless ($mirby) {
       warn "error: no mirror data available for channel $channel\n";
       channel_failed("channel: MIRRORED.BY contents were missing");
@@ -1012,25 +1020,20 @@
   my($query) = shift;
 
   my $RR = $res->query($query, 'TXT');
-  my $result = '';
+  my @result;
 
   if ($RR) {
     foreach my $rr ($RR->answer) {
       my $text = $rr->rdatastr;
       $text =~ /^"(.*)"$/;
-      if (length $result) {
-	$result .= " $1";
-      }
-      else {
-        $result = $1;
-      }
+      push @result, $1;
     }
   }
   else {
     dbg("dns: query failed: $query => " . $res->errorstring);
   }
 
-  return $result;
+  return @result;
 }
 
 ##############################################################################