spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r280718 - in /spamassassin/branches/3.1/lib/Mail/SpamAssassin: Logger.pm Plugin/DCC.pm Plugin/DomainKeys.pm Plugin/Pyzor.pm Plugin/Razor2.pm Plugin/SPF.pm
Date Tue, 13 Sep 2005 23:41:22 GMT
Author: dos
Date: Tue Sep 13 16:41:18 2005
New Revision: 280718

URL: http://svn.apache.org/viewcvs?rev=280718&view=rev
Log:
Intermittent __alarm__ errors with various plugins

Modified:
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Logger.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DCC.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DomainKeys.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Pyzor.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Razor2.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/SPF.pm

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Logger.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Logger.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Logger.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Logger.pm Tue Sep 13 16:41:18 2005
@@ -140,6 +140,9 @@
   # return unless $message[0] =~ /^\S+:/;
   # }
 
+  # dos: don't log alarm timeouts or broken pipes of various plugins' network checks
+  return if ($level eq "error" && $message[0] =~ /__(?:alarm|brokenpipe)__ignore__/);
+
   my $message = join(" ", @message);
   $message =~ s/[\r\n]+$//;		# remove any trailing newlines
 

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DCC.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DCC.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DCC.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DCC.pm Tue Sep 13 16:41:18 2005
@@ -344,7 +344,7 @@
   eval {
     # safe to use $SIG{ALRM} here instead of Util::trap_sigalrm_fully(),
     # since there are no killer regexp hang dangers here
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
 
     $oldalarm = alarm $timeout;
 
@@ -383,19 +383,21 @@
 
     dbg("dcc: dccifd got response: $response");
 
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
-  # do NOT reinstate $oldalarm here; we may already have done that in
-  # the success case.  leave it to the error handler below
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
   $permsgstatus->leave_helper_run_mode();
 
   if ($err) {
-    alarm $oldalarm;
     chomp $err;
     $response = undef;
-    if ($err =~ /__alarm__/) {
+    if ($err eq "__alarm__ignore__") {
       dbg("dcc: dccifd check timed out after $timeout secs.");
       return 0;
     } else {
@@ -461,8 +463,8 @@
   eval {
     # safe to use $SIG{ALRM} here instead of Util::trap_sigalrm_fully(),
     # since there are no killer regexp hang dangers here
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
-    local $SIG{PIPE} = sub { die "__brokenpipe__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
+    local $SIG{PIPE} = sub { die "__brokenpipe__ignore__\n" };
 
     $oldalarm = alarm $timeout;
 
@@ -504,12 +506,16 @@
 
     # note: this must be called BEFORE leave_helper_run_mode()
     # $self->cleanup_kids($pid);
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
-  # do NOT reinstate $oldalarm here; we may already have done that in
-  # the success case.  leave it to the error handler below
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
+
   if (defined(fileno(*DCC))) {  # still open
     if ($pid) {
       if (kill('TERM',$pid)) { dbg("dcc: killed stale helper [$pid]") }
@@ -521,11 +527,10 @@
   $permsgstatus->leave_helper_run_mode();
 
   if ($err) {
-    alarm $oldalarm;
     chomp $err;
-    if ($err =~ /^__alarm__$/) {
+    if ($err eq "__alarm__ignore__") {
       dbg("dcc: check timed out after $timeout seconds");
-    } elsif ($err =~ /^__brokenpipe__$/) {
+    } elsif ($err eq "__brokenpipe__ignore__") {
       dbg("dcc: check failed: broken pipe");
     } elsif ($err eq "no response") {
       dbg("dcc: check failed: no response");
@@ -607,8 +612,8 @@
   my $oldalarm = 0;
 
   eval {
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
-    local $SIG{PIPE} = sub { die "__brokenpipe__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
+    local $SIG{PIPE} = sub { die "__brokenpipe__ignore__\n" };
 
     $oldalarm = alarm $timeout;
 
@@ -625,20 +630,23 @@
     $options->{report}->close_pipe_fh(\*DCC);
 
     waitpid ($pid, 0);
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
 
-  # do not call alarm $oldalarm here, that *may* have already taken place
   $options->{report}->leave_helper_run_mode();
 
   if ($err) {
-    alarm $oldalarm;  # reinstate the one we missed
     chomp $err;
-    if ($err =~ /^__alarm__$/) {
+    if ($err eq "__alarm__ignore__") {
       dbg("reporter: DCC report timed out after $timeout seconds");
-    } elsif ($err =~ /^__brokenpipe__$/) {
+    } elsif ($err eq "__brokenpipe__ignore__") {
       dbg("reporter: DCC report failed: broken pipe");
     } else {
       warn("reporter: DCC report failed: $err\n");

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DomainKeys.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DomainKeys.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DomainKeys.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/DomainKeys.pm Tue Sep 13 16:41:18
2005
@@ -137,20 +137,25 @@
   }
 
   my $timeout = 5;              # TODO: tunable timeout
-  my $oldalarm;
+  my $oldalarm = 0;
 
   eval {
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
     $oldalarm = alarm($timeout);
     $self->_dk_lookup_trapped($scan, $message, $domain);
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
 
   if ($err) {
-    alarm $oldalarm;
-    if ($err =~ /^__alarm__$/) {
+    chomp $err;
+    if ($err eq "__alarm__ignore__") {
       dbg("dk: lookup timed out after $timeout seconds");
     } else {
       warn("dk: lookup failed: $err\n");

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Pyzor.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Pyzor.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Pyzor.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Pyzor.pm Tue Sep 13 16:41:18 2005
@@ -228,8 +228,8 @@
   eval {
     # safe to use $SIG{ALRM} here instead of Util::trap_sigalrm_fully(),
     # since there are no killer regexp hang dangers here
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
-    local $SIG{PIPE} = sub { die "__brokenpipe__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
+    local $SIG{PIPE} = sub { die "__brokenpipe__ignore__\n" };
 
     $oldalarm = alarm $timeout;
 
@@ -262,12 +262,20 @@
 
     # note: this must be called BEFORE leave_helper_run_mode()
     # $self->cleanup_kids($pid);
-    alarm $oldalarm;
+
+    # attempt to call this inside the eval, as leaving this scope is
+    # a slow operation and timing *that* out is pointless
+    if (defined $oldalarm) { 
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
-  # do NOT reinstate $oldalarm here; we may already have done that in
-  # the success case.  leave it to the error handler below
+  # clear the alarm before doing lots of time-consuming hard work
   my $err = $@;
+  if (defined $oldalarm) { 
+    alarm $oldalarm; $oldalarm = undef;
+  }
+
   if (defined(fileno(*PYZOR))) {  # still open
     if ($pid) {
       if (kill('TERM',$pid)) { dbg("pyzor: killed stale helper [$pid]") }
@@ -279,11 +287,10 @@
   $permsgstatus->leave_helper_run_mode();
 
   if ($err) {
-    alarm $oldalarm;
     chomp $err;
-    if ($err eq "__alarm__") {
+    if ($err eq "__alarm__ignore__") {
       dbg("pyzor: check timed out after $timeout seconds");
-    } elsif ($err eq "__brokenpipe__") {
+    } elsif ($err eq "__brokenpipe__ignore__") {
       dbg("pyzor: check failed: broken pipe");
     } elsif ($err eq "no response") {
       dbg("pyzor: check failed: no response");
@@ -351,8 +358,8 @@
   my $oldalarm = 0;
 
   eval {
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
-    local $SIG{PIPE} = sub { die "__brokenpipe__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
+    local $SIG{PIPE} = sub { die "__brokenpipe__ignore__\n" };
 
     $oldalarm = alarm $timeout;
 
@@ -370,21 +377,23 @@
     my @ignored = <PYZOR>;
     $options->{report}->close_pipe_fh(\*PYZOR);
 
-    alarm $oldalarm;
+    if (defined $oldalarm) { 
+      alarm $oldalarm; $oldalarm = undef;
+    }
     waitpid ($pid, 0);
   };
 
   my $err = $@;
-
-  # do not call alarm $oldalarm here, that *may* have already taken place
+  if (defined $oldalarm) { 
+    alarm $oldalarm; $oldalarm = undef;
+  }
   $options->{report}->leave_helper_run_mode();
 
   if ($err) {
-    alarm $oldalarm;
     chomp $err;
-    if ($err eq '__alarm__') {
+    if ($err eq '__alarm__ignore__') {
       dbg("reporter: pyzor report timed out after $timeout seconds");
-    } elsif ($err eq '__brokenpipe__') {
+    } elsif ($err eq '__brokenpipe__ignore__') {
       dbg("reporter: pyzor report failed: broken pipe");
     } else {
       warn("reporter: pyzor report failed: $err\n");

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Razor2.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Razor2.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Razor2.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/Razor2.pm Tue Sep 13 16:41:18 2005
@@ -148,7 +148,7 @@
   eval {
     local ($^W) = 0;    # argh, warnings in Razor
 
-    local $SIG{ALRM} = sub { die "alarm\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
     $oldalarm = alarm $timeout;
 
     # everything's in the module!
@@ -220,7 +220,9 @@
 	}
 
 	# if we got here, we're done doing remote stuff, abort the alert
-	alarm 0;
+        if (defined $oldalarm) {
+          alarm $oldalarm; $oldalarm = undef;
+        }
 
 	# Razor 2.14 says that if we get here, we did ok.
 	$return = 1;
@@ -295,18 +297,19 @@
       warn "$debug: undefined Razor2::Client::Agent\n";
     }
   
-    # note: this may be a double-reset.  not a big deal though; the
-    # result should only be the extension of a preexisting timeout
-    # by < 1 sec.
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
 
   if ($err) {
-    alarm $oldalarm;    # just in case
     chomp $err;
-    if ($err =~ /alarm/) {
+    if ($err eq "__alarm__ignore__") {
       dbg("$debug: razor2 $type timed out after $timeout seconds");
     } elsif ($err =~ /(?:could not connect|network is unreachable)/) {
       # make this a dbg(); SpamAssassin will still continue,

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/SPF.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/SPF.pm?rev=280718&r1=280717&r2=280718&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/SPF.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Plugin/SPF.pm Tue Sep 13 16:41:18 2005
@@ -287,20 +287,25 @@
 
   my ($result, $comment);
   my $timeout = 5;
-  my $oldalarm;
+  my $oldalarm = 0;
 
   eval {
-    local $SIG{ALRM} = sub { die "__alarm__\n" };
+    local $SIG{ALRM} = sub { die "__alarm__ignore__\n" };
     $oldalarm = alarm($timeout);
     ($result, $comment) = $query->result();
-    alarm $oldalarm;
+    if (defined $oldalarm) {
+      alarm $oldalarm; $oldalarm = undef;
+    }
   };
 
   my $err = $@;
+  if (defined $oldalarm) {
+    alarm $oldalarm; $oldalarm = undef;
+  }
 
   if ($err) {
-    alarm $oldalarm;
-    if ($err =~ /^__alarm__$/) {
+    chomp $err;
+    if ($err eq "__alarm__ignore__") {
       dbg("spf: lookup timed out after $timeout seconds");
     } else {
       warn("spf: lookup failed: $err\n");



Mime
View raw message