[Mimedefang] Setting clamd timeouts.

Matthew Schumacher matt.s at aptalaska.net
Thu Sep 27 00:56:30 EDT 2007

David F. Skoll wrote:
> Matthew Schumacher wrote:
>> That is really interesting that you say that, I just got done explaining
>> to another staff member that making mimedefang robust enough to handle
>> clamd brown outs without timing out every process would be the better
>> solution than kicking clamd because one makes mimedefang more robust and
>> the other is a hack to fix clamd.
> Well, here's the thing.  Suppose MIMEDefang has a clamd timeout.
> What do you do in that case?
> 1) Tempfail the mail?  Then what's the advantage over just using the
> normal MIMEDefang overall timeout (apart, possibly, from better logging)?
> 2) Allow the mail through?  Ehmm... nope.

Well for one, my system bounces with a tempfail when the virus scanner
is unavailable which means that if there was a clamd timeout I would
tempfail the message every 20 seconds instead of every 2 minutes which
is what my slave timeout is set to.  Also, because I announce what is
wrong in the tempfail message users would get a message in 20 seconds
saying the virus scanner failed instead a message in 2 minutes saying it
didn't work.

I suppose I could adjust my slave timeout, but if clamd takes more than
20 seconds something is wrong where spamassassin could take much longer.

Anyway, does anyone see anything wrong with the attached patch?  I'm not
much for programming with sockets.

-------------- next part --------------
--- /usr/bin/mimedefang.pl      2007-08-29 09:12:12.000000000 -0800
+++ /tmp/mimedefang.pl  2007-09-26 20:42:52.000000000 -0800
@@ -4381,6 +4381,7 @@
     my $sock = IO::Socket::UNIX->new(Peer => $clamd_sock);
     if (defined $sock) {
+        $sock->timeout(20);
        my $path = $entity->bodyhandle->path;
        # If path is not absolute, add cwd
        if (! ($path =~ m+^/+)) {
@@ -4452,6 +4453,8 @@
        return (wantarray ? (999, 'cannot-execute', 'tempfail') : 999);

+    $sock->timeout(20);
     my $s = IO::Select->new();
     if (!$s->can_write(30)) {

More information about the MIMEDefang mailing list