------------------------------------------------------------ revno: 13512 revision-id: squid3@treenet.co.nz-20140725120142-cunk1lyx6zrvbrt2 parent: squid3@treenet.co.nz-20140724102217-nsr009o91yu3iwbb committer: Amos Jeffries branch nick: trunk timestamp: Fri 2014-07-25 05:01:42 -0700 message: Optimize Comm::Connection IP::address setting Use an inline setter to set both local and remote IP address values in one call. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140725120142-cunk1lyx6zrvbrt2 # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: ea45da42ff16251c5df29f90b87b7718ef3e4c75 # timestamp: 2014-07-25 12:53:56 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140724102217-\ # nsr009o91yu3iwbb # # Begin patch === modified file 'src/comm/Connection.cc' --- src/comm/Connection.cc 2014-07-10 14:47:53 +0000 +++ src/comm/Connection.cc 2014-07-25 12:01:42 +0000 @@ -45,8 +45,7 @@ { ConnectionPointer c = new Comm::Connection; - c->local = local; - c->remote = remote; + c->setAddrs(local, remote); c->peerType = peerType; c->tos = tos; c->nfmark = nfmark; === modified file 'src/comm/Connection.h' --- src/comm/Connection.h 2014-07-10 14:47:53 +0000 +++ src/comm/Connection.h 2014-07-25 12:01:42 +0000 @@ -104,6 +104,11 @@ /** determine whether this object describes an active connection or not. */ bool isOpen() const { return (fd >= 0); } + /** Alter the stored IP address pair. + * WARNING: Does not ensure matching IPv4/IPv6 are supplied. + */ + void setAddrs(const Ip::Address &aLocal, const Ip::Address &aRemote) {local = aLocal; remote = aRemote;} + /** retrieve the CachePeer pointer for use. * The caller is responsible for all CBDATA operations regarding the * used of the pointer returned. === modified file 'src/dns_internal.cc' --- src/dns_internal.cc 2014-06-05 14:57:58 +0000 +++ src/dns_internal.cc 2014-07-25 12:01:42 +0000 @@ -899,15 +899,12 @@ Comm::ConnectionPointer conn = new Comm::Connection(); if (!Config.Addrs.udp_outgoing.isNoAddr()) - conn->local = Config.Addrs.udp_outgoing; + conn->setAddrs(Config.Addrs.udp_outgoing, nameservers[nsv].S); else - conn->local = Config.Addrs.udp_incoming; - - conn->remote = nameservers[nsv].S; - - if (conn->remote.isIPv4()) { + conn->setAddrs(Config.Addrs.udp_incoming, nameservers[nsv].S); + + if (conn->remote.isIPv4()) conn->local.setIPv4(); - } AsyncCall::Pointer call = commCbCall(78,3, "idnsInitVCConnected", CommConnectCbPtrFun(idnsInitVCConnected, vc)); === modified file 'src/ftp.cc' --- src/ftp.cc 2014-07-21 14:55:27 +0000 +++ src/ftp.cc 2014-07-25 12:01:42 +0000 @@ -2468,9 +2468,8 @@ // Generate a new data channel descriptor to be opened. Comm::ConnectionPointer conn = new Comm::Connection; - conn->local = ftpState->ctrl.conn->local; + conn->setAddrs(ftpState->ctrl.conn->local, ftpState->ctrl.conn->remote); conn->local.port(0); - conn->remote = ftpState->ctrl.conn->remote; conn->remote.port(port); conn->tos = ftpState->ctrl.conn->tos; conn->nfmark = ftpState->ctrl.conn->nfmark; @@ -2724,9 +2723,8 @@ ftpState->ctrl.last_command = xstrdup("Connect to server data port"); Comm::ConnectionPointer conn = new Comm::Connection; - conn->local = ftpState->ctrl.conn->local; + conn->setAddrs(ftpState->ctrl.conn->local, ipaddr); conn->local.port(0); - conn->remote = ipaddr; conn->remote.port(port); debugs(9, 3, HERE << "connecting to " << conn->remote);