You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2009/11/25 18:12:57 UTC

svn commit: r884199 - in /spamassassin/trunk: lib/Mail/SpamAssassin.pm lib/Mail/SpamAssassin/Conf.pm spamd/spamd.raw

Author: mmartinec
Date: Wed Nov 25 17:12:56 2009
New Revision: 884199

URL: http://svn.apache.org/viewvc?rev=884199&view=rev
Log:
Bug 6238: change a default for time_limit option from unlimited
to 300 s (consistent with a spamd default);  let spamd override
the deadline according to its own --timeout-child option value;
spamd: just 'use' the Time::HiRes (which is now a required module),
instead of probing for it with an eval-ed 'require'

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/lib/Mail/SpamAssassin.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin.pm?rev=884199&r1=884198&r2=884199&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin.pm Wed Nov 25 17:12:56 2009
@@ -1455,7 +1455,7 @@
   $self->{'conf'}->{'use_auto_whitelist'} = 0;
   $self->{'conf'}->{'bayes_auto_learn'} = 0;
 
-  my $mail = $self->parse(\@testmsg, 1);
+  my $mail = $self->parse(\@testmsg, 1, { master_deadline => undef });
   my $status = Mail::SpamAssassin::PerMsgStatus->new($self, $mail,
                         { disable_auto_learning => 1 } );
   $status->check();

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=884199&r1=884198&r2=884199&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Wed Nov 25 17:12:56 2009
@@ -1573,11 +1573,12 @@
 
 =over 4
 
-=item time_limit n   (default: 0, i.e. unlimited)
+=item time_limit n   (default: 300)
 
 Specifies a limit on elapsed time in seconds that SpamAssassin is allowed
-to spend before providing a result. The value may be fractional and must not
-be negative, zero is interpreted as unlimited and is a default.
+to spend before providing a result. The value may be fractional and must
+not be negative, zero is interpreted as unlimited. The default is 300
+seconds for consistency with the spamd default setting of --timeout-child .
 
 This is a best-effort advisory setting, processing will not be abruptly
 aborted at an arbitrary point in processing when the time limit is exceeded,
@@ -1589,10 +1590,14 @@
 
 When a message is passed to Mail::SpamAssassin::parse, a deadline time
 is established as a sum of current time and the C<time_limit> setting.
+
 This deadline may be overruled by a caller through option 'master_deadline'
 in $suppl_attrib on a call to parse(), possibly providing a more accurate
 deadline taking into account past and expected future processing of a
-message in a mail filtering setup.
+message in a mail filtering setup. Note that spamd (and possibly some
+third-party callers of SpamAssassin) will overrule the C<time_limit> setting
+based on its --timeout-child option, unlike the command line C<spamassassin>,
+which has no such command line option.
 
 When a time limit is exceeded, most of the remaining tests will be skipped,
 as well as auto-learning. Whatever tests fired so far will determine the
@@ -1615,7 +1620,7 @@
 
   push (@cmds, {
     setting => 'time_limit',
-    default => 0,
+    default => 300,
     type => $CONF_TYPE_NUMERIC,
     code => sub {
       my ($self, $key, $value, $line) = @_;

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamd/spamd.raw?rev=884199&r1=884198&r2=884199&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Wed Nov 25 17:12:56 2009
@@ -101,6 +101,7 @@
 use File::Spec 0.8;
 use File::Path;
 use Carp ();
+use Time::HiRes qw(time);
 
 use constant RUNNING_ON_MACOS => ($^O =~ /^darwin/oi);
 
@@ -110,10 +111,7 @@
   die 'spamd: spamd script is v@@VERSION@@, but using modules v'.$Mail::SpamAssassin::VERSION."\n";
 }
 
-# Load Time::HiRes if it's available
 BEGIN {
-  eval { require Time::HiRes };
-  Time::HiRes->import(qw(time)) unless $@;
   # redirect __WARN__ and __DIE__
   # do not trap warnings here based on eval scope; evals are very
   # common throughout.  die()s can be trapped though.
@@ -1381,7 +1379,8 @@
   
   # Now parse *only* the message headers; the MIME tree won't be generated 
   # yet, it will be done on demand later on.
-  my $mail = $spamtest->parse(\@msglines, 0);
+  my $mail = $spamtest->parse(\@msglines, 0,
+         !$timeout_child ? () : { master_deadline => time + $timeout_child } );
 
   return ($mail, $actual_length);
 }