https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8518

            Bug ID: 8518
           Summary: On Windows, a DNS lookup fails when DnsResolver binds
                    a port in an excluded port range
           Product: Spamassassin
           Version: SVN Trunk (Latest Devel Version)
          Hardware: PC
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Libraries
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: Undefined

Created attachment 6220
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6220&action=edit
Try another local port after any bind failure

On Windows, DNS lookups occasionally fail with "dns: error creating a DNS
resolver socket: Permission denied", which shows up as intermittent failures of
t/askdns.t and t/hashbl.t.

DnsResolver::connect_sock binds the query socket to a random local port, and
tries another port when the bind fails with EADDRINUSE or EACCES. Binding a
port in one of Windows' excluded port ranges fails with "Permission denied",
but with Strawberry Perl 5.36 and older, $! no longer holds EACCES when
IO::Socket::IP->new returns, although $@ has the message. So connect_sock does
not try another port, and the lookup fails. Strawberry Perl 5.38 and later keep
EACCES in $!.

The attached patch tries another port after any bind failure when a specific
local port was chosen, up to the existing limit of 50 attempts. Since a
persistent error now reaches that limit, the limit ends the loop without a
warning of its own, so the warning after the loop reports the last error
instead of a second warning ending in ": 0".

The change is not specific to Windows, but elsewhere the bind normally
succeeds, and nothing changes. When creating the socket fails for another
reason, such as an unreachable network, the lookup still fails after a couple
of milliseconds of retries, and the warning reads "could not create a DNS
resolver socket in 50 attempts: Network is unreachable" instead of "error
creating a DNS resolver socket: Network is unreachable".

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to