Bug 5256: Intercepting port fails to accept (#1238)
ERROR: NF getsockopt(ORIGINAL_DST) failed on ... Bad file descriptor
ERROR: NAT lookup failed to locate original IPs on ...
Ip::Interceptor.LookupNat() needs an open Connection, but commit
7185c9e
supplied a half-baked details object, resulting in ERRORs (showing a
closed connection -- no FD... field) for every otherwise successful
accept(2) attempt on an intercepting port.
Refactored oldAccept() to use exceptions for error handling and false
return result for no-error-but-no-connection cases (Comm::NOMESSAGE).
This refactoring allows us to centralize connection closing code instead
of chasing individual COMM_ERROR and NOMESSAGE cases while still missing
connection closure (if a function called by oldAccept() throws). With
connection closure handled, we can now open the details Connection
earlier, as we have done before commit
7185c9e, meeting current
LookupNat() and other/future code expectations.
Positive side effects of this fix include elimination of the following
old error reporting problems that left admins puzzled why Squid is not
handling new connections with no error messages in non-debugging
cache.log (and with the socket listening queue growing).
* Silent lack of accept() after an ENFILE or EMFILE failure.
* Silent lack of accept() if some function used by oldAccept() throws.
* Silent at level-0 lack of accept() after logging a level-1 ERROR. This
problem was specific to ALL,0 and similar (rare) configurations.