You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2006/04/04 22:49:23 UTC
svn commit: r391410 - /spamassassin/trunk/spamd/spamd.raw
Author: dos
Date: Tue Apr 4 13:49:23 2006
New Revision: 391410
URL: http://svn.apache.org/viewcvs?rev=391410&view=rev
Log:
bug 4699: use M::SA::Timeout for copy_config call
Modified:
spamassassin/trunk/spamd/spamd.raw
Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/spamd/spamd.raw?rev=391410&r1=391409&r2=391410&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Tue Apr 4 13:49:23 2006
@@ -43,6 +43,7 @@
use Mail::SpamAssassin::SubProcBackChannel;
use Mail::SpamAssassin::SpamdForkScaling qw(:pfstates);
use Mail::SpamAssassin::Logger qw(:DEFAULT log_message);
+use Mail::SpamAssassin::Timeout;
use Getopt::Long;
use Pod::Usage;
@@ -937,20 +938,15 @@
}
}
- if ($copy_config_p)
- {
+ if ($copy_config_p) {
# use a timeout! There are bugs in Storable on certain platforms
# that can cause spamd to hang -- see bug 3828 comment 154.
# we don't use Storable any more, but leave this in -- just
# in case.
- # dos: under high load an alarm may fire while $@ will contain ""
- # which isn't very useful... workaround with $timedout counter, which
- # is safe since it doesn't require malloc() being called, see bug 4699
- my $oldalarm = 0;
- my $timedout = 0;
- eval {
- local $SIG{ALRM} = sub { $timedout++; die "__alarm__\n" };
- $oldalarm = alarm 10;
+ # bug 4699: this is the alarm that often ends up with an empty $@
+
+ my $timer = Mail::SpamAssassin::Timeout->new({ secs => 20 });
+ my $err = $timer->run(sub {
while(my($k,$v) = each %msa_backup) {
$spamtest->{$k} = $v;
@@ -960,26 +956,13 @@
# (potentially), so let's restore back the saved version we
# had before.
$spamtest->copy_config(\%conf_backup, undef) ||
- die "error returned from copy_config\n";
- alarm $oldalarm;
- };
-
- alarm $oldalarm;
- my $err = $@;
-
- if ($err) {
- if ($err =~ /__alarm__/) {
- warn("spamd: copy_config timeout, respawning child process after ".
- ($i+1)." messages");
- exit; # so that the master spamd can respawn
+ die "spamd: error returned from copy_config\n";
+ });
- } else {
- die $err; # propagate failures
- }
- } elsif ($timedout) {
- warn("spamd: copy_config timeout (with empty \$@), respawning ".
- "child process after ".($i+1)." messages");
- exit; # so that the master spamd can respawn
+ if ($timer->timed_out()) {
+ warn("spamd: copy_config timeout, respawning child process after ".
+ ($i+1)." messages");
+ exit; # so that the master spamd can respawn
}
}
undef $current_user;