David,

> 2. amavisd-milter requires to use Unix domain sockets to communicate
>    with amavisd. This is not really a problem except that when I was
>    stress-testing my test setup with 10 backend amavisd processes, I
>    noticed that, once in a while, amavisd-milter was getting a
>    "Connection refused" on the socket.
>
>    The problem is that even though I properly limited the number of
>    amavisd connections in amavisd-milter, amavisd does have a listen
>    backlog (queuing of connecting clients) of maximum 5 clients. That
>    is, if I have configured to use at most 10 amavisd processes and by
>    chance 6 amavisd-milter processes try to establish a connection
>    simultaneously, it will fail.

I don't see why it would be 5. The program flow goes like:

amavisd leaves Net::Server's option 'listen' at a default.

Net::Server.pm turns undef into 128:
  $prop->{listen} = Socket::SOMAXCONN()
    unless defined($prop->{listen}) && $prop->{listen} =~ /^\d{1,3}$/;

Net::Server::Proto::Unix.pm:
  if( $unix_type != SOCK_DGRAM ){
    $args{Listen} = $prop->{listen};  # how many connections for kernel to queue
  }

Inserting a debug printout for $lport into IO::Socket::UNIX.pm like:

    if(exists $arg->{Listen} && $type != SOCK_DGRAM) {
printf STDERR ("HERE: %s\n", $arg->{Listen});
        $sock->listen($arg->{Listen} || 5) or
            return undef;
    }

and starting 'amavisd foreground' gives me 128, the same as for INET sockets.

>    That's why, it would be useful to have in amavisd a variable called
>    $listen_backlog or something like that, which would allow you to
>    specify the queue size for the listen sockets. amavisd would then
>    just need to pass this as 'listen' parameter to Net::Server...

--- amavisd.orig        Wed Jun 27 12:43:00 2007
+++ amavisd     Fri Jul 27 17:48:57 2007
@@ -282,5 +282,5 @@
       $child_timeout $smtpd_timeout
       %current_policy_bank %policy_bank %interface_policy
-      $unix_socketname $inet_socket_port $inet_socket_bind
+      $unix_socketname $inet_socket_port $inet_socket_bind $listen_queue_size
       $relayhost_is_client $smtpd_recipient_limit
       $enforce_smtpd_message_size_limit_64kb_min
@@ -11444,4 +11444,5 @@
     host => (!defined($inet_socket_bind) || $inet_socket_bind eq '' ? '*'
                                                           : $inet_socket_bind),
+    listen => defined $listen_queue_size ? $listen_queue_size : undef,
     max_servers => defined $max_servers_override ? $max_servers_override
                                : $max_servers,  # number of pre-forked children

Unfortunately Net::Server does not allow to specify listen backlog queue size
individually for each socket.

>    Note that this is also not really an issue with inet sockets because
>    of the way connections to inet sockets are handled: if there is no
>    free space in the connection queue, the SYN packet is just dropped
>    so that the client comes back later. With unix sockets, it is not
>    possible to do that so the client gets immediately a connection
>    refused.

'netstat -L -a' is showing me 128 for all amavisd sockets.

  Mark

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
AMaViS-user mailing list
[email protected]
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