Chaminda Indrajith,

> I have installed amavisd-new with ClamAV in our mail server. But when
> mail scanning, the following error message is appeared in the mail
> log.
>
> May 22 12:09:52 mail amavis[34579]: (34550-01) (!!)[34579]
> run_as_subprocess: child done (3.2 ms), sending results: res_len=79,
> STATUS: FAILURE run_av error: Exceeded allowed time at (eval 99) line
> 512.
> My Amavisd-new version
> amavisd-new-2.6.0 (20080423)

The following patch should fix it (with some additional safety belts
and additional logging). The problem is specific to running Mail::ClamAV,
which is executed as a subprocess of amavisd, and a timer was not
restarted in a subprocess.

My general advice is to avoid using Mail::ClamAV. It loads clamav
code and virus fingerprints database into a Perl process, which can
noticable increase a virtual memory footprint of amavisd, and increases
security risks by running virus-checking code in the same process as
the rest of perl. I'd suggest to use clamd (the daemonized clamav)
instead of Mail::ClamAV, it is just as fast, but without ill-effects.

Thanks for the bug report.



--- amavisd.orig        2008-04-23 20:50:05.000000000 +0200
+++ amavisd     2008-05-22 22:15:51.000000000 +0200
@@ -2685,5 +2685,5 @@
                   &collect_results &collect_results_structured);
   import Amavis::Conf qw(:platform);
-  import Amavis::Util qw(ll do_log);  # freeze thaw
+  import Amavis::Util qw(ll do_log prolong_timer);  # freeze thaw
   import Amavis::Log qw(open_log close_log log_fd);
 }
@@ -2974,4 +2974,5 @@
 sub run_as_subprocess($@) {
   my($code,@args) = @_;
+  my($remaining_time) = alarm(0);  # check time left, stop the timer
   my($pid); my($proc_fh) = IO::File->new;
   eval {
@@ -2983,5 +2984,5 @@
   defined($pid) or die "run_as_subprocess: can't fork: $!";
   if (!$pid) {  # child
-    alarm(0);   # stop the timer, timeouts will be handled by a parent process
+    # timeouts will be also be handled by a parent process
     my($t0) = Time::HiRes::time; my(@result); my($interrupt) = '';
     my($h1) = sub { $interrupt = $_[0] };
@@ -2994,4 +2995,5 @@
       local(@SIG{qw(INT HUP TERM TSTP QUIT USR1 USR2)}) = ($h2) x 7;
       if ($interrupt ne '') { my($i) = $interrupt; $interrupt = ''; die $i }
+      prolong_timer("child[$$]", $remaining_time);  # restart the timer
       release_parent_resources();
       binmode(STDOUT) or die "Can't set STDOUT to binmode: $!";
@@ -3036,4 +3038,5 @@
   ll(5) && do_log(5,"run_as_subprocess: spawned a subprocess [%s]", $pid);
   binmode($proc_fh) or die "Can't set pipe to binmode: $!";  # dflt Perl 5.8.1
+  prolong_timer('run_as_subprocess', $remaining_time);  # restart the timer
   ($proc_fh, $pid);  # return pipe file handle to the subprocess and its PID
 }
@@ -19086,5 +19089,6 @@
   my($multisession) = $av_name =~ /\b(Sophie|Trophie|fpscand)\b/i ? 1 : 0;
   my($remaining_time) = alarm(0);  # check time left, stop the timer
-  my($deadline) = time + $remaining_time;
+  do_log(5, "ask_daemon_internal: timer was stopped")  if $remaining_time <= 0;
+  my($deadline) = time + max(10,$remaining_time);
   local $SIG{PIPE} = 'IGNORE';  # 'send' to a broken pipe would throw a signal
   for (;;) {  # gracefully handle cases when av process times out or restarts
@@ -19225,5 +19229,6 @@
         @query_template;
   my($remaining_time) = alarm(0);  # check time left, stop the timer
-  my($deadline) = time + $remaining_time;
+  do_log(5, "run_av: timer was stopped")  if $remaining_time <= 0;
+  my($deadline) = time + max(10,$remaining_time);
   prolong_timer('run_av', $deadline - time);  # restart timer
   my($eval_stat);



Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/amavis-user
AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3
AMaViS-HowTos:http://www.amavis.org/howto/

Reply via email to