From: Amos Jeffries Date: Sun, 17 Oct 2010 10:20:35 +0000 (-0600) Subject: Fix Regression: SMP broke ICP outgoing IP lookup if no udp_outgoing_addr set X-Git-Tag: take1~170 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=236dedc038f6b479bc4939376072ff4def1a6b24;p=thirdparty%2Fsquid.git Fix Regression: SMP broke ICP outgoing IP lookup if no udp_outgoing_addr set --- diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 692eed66b2..4ac84b08fc 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -676,9 +676,6 @@ icpConnectionsOpen(void) uint16_t port; Ip::Address addr; - struct addrinfo *xai = NULL; - int x; - if ((port = Config.Port.icp) <= 0) return; @@ -738,15 +735,18 @@ icpConnectionsOpen(void) debugs(12, 1, "Outgoing ICP messages on port " << addr.GetPort() << ", FD " << theOutIcpConnection << "."); fd_note(theOutIcpConnection, "Outgoing ICP socket"); + icpGetOutgoingIpAddress(); } +} +static void +icpGetOutgoingIpAddress() +{ + struct addrinfo *xai = NULL; theOutICPAddr.SetEmpty(); - theOutICPAddr.InitAddrInfo(xai); - x = getsockname(theOutIcpConnection, xai->ai_addr, &xai->ai_addrlen); - - if (x < 0) + if (getsockname(theOutIcpConnection, xai->ai_addr, &xai->ai_addrlen) < 0) debugs(50, 1, "theOutIcpConnection FD " << theOutIcpConnection << ": getsockname: " << xstrerror()); else theOutICPAddr = *xai; @@ -775,8 +775,10 @@ icpIncomingConnectionOpened(int fd, int errNo, Ip::Address& addr) fd_note(theInIcpConnection, "Incoming ICP socket"); - if (Config.Addrs.udp_outgoing.IsNoAddr()) + if (Config.Addrs.udp_outgoing.IsNoAddr()) { theOutIcpConnection = theInIcpConnection; + icpGetOutgoingIpAddress(); + } } /**