]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 5256: Intercepting port fails to accept (#1238)
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 13 Jan 2023 22:33:35 +0000 (22:33 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 14 Jan 2023 16:04:26 +0000 (16:04 +0000)
commit5be73e828a5cda5c386f79ace9730bb3b045c39e
tree4c9f0d1265993c7a9517a497498c97e1831a3dfa
parent337b9aa4786047dfd90bac5ebf0ac4b4a475fc03
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.
src/comm/Flag.h
src/comm/TcpAcceptor.cc
src/comm/TcpAcceptor.h
src/fd.cc
src/fd.h