SpamAssassin version 3.1.4
  running on Perl version 5.8.7
SunOS email 5.9 Generic_118558-10 sun4u sparc SUNW,Sun-Fire-V210

In the connect_sock() method in DnsResolver.pm, there is a loop starting
at line 177 that starts out like this:

  # find next available unprivileged port (1024 - 65535)
  # starting at a random value to spread out use of ports
  my $port_offset = int(rand(64511));  # 65535 - 1024
  for (my $i = 0; $i<64511; $i++) {
    my $lport = 1024 + (($port_offset + $i) % 64511);

So it picks out a random number in the 1024-65535 range, and uses it as
the LocalPort option to IO::Socket::INET().  If it gets a EADDRINUSE
error, it tries the next number in sequence for LocalPort.  If it gets
any other error, it gives up trying to create the socket.

The problem is that on our (Solaris) system, the socket creation
sometimes fails with EACCES rather than EADDRINUSE.  This causes the
code to give up when it could have succeeded by just trying another
local port number.

1) Could the code be changed to treat EACCES the same as EADDRINUSE?

2) Better yet, why is the code trying to specify the LocalPort number
instead of letting the system pick one?

Thanks, Larry

Reply via email to