From 6185ad8c66728a257e0c49c5eb434f33fc3971fd Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Thu, 21 Nov 2019 08:19:47 +0000 Subject: [PATCH] Happy Eyeballs: Do not wait for already exhausted spares (#509) ResolvedPeers::findSpareOrNextPeer() never returned the next peer. That bug made doneWithSpares() return false when the next peer was present, even though no spares were expected. The exact effects of this bug are not known, but wrong false doneWithSpares() outcome may force Squid to wait for more spare addresses that would never come, possibly slowing down transactions. --- src/ResolvedPeers.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/ResolvedPeers.cc b/src/ResolvedPeers.cc index 4cfbf20505..f7620134e2 100644 --- a/src/ResolvedPeers.cc +++ b/src/ResolvedPeers.cc @@ -65,14 +65,11 @@ ResolvedPeers::findSpareOrNextPeer(const Comm::Connection ¤tPeer) const auto familyToAvoid = ConnectionFamily(currentPeer); // Optimization: Also stop at the first mismatching peer because all // same-peer paths are grouped together. - auto found = std::find_if(paths_.begin(), paths_.end(), + return std::find_if(paths_.begin(), paths_.end(), [peerToMatch, familyToAvoid](const Comm::ConnectionPointer &conn) { return peerToMatch != conn->getPeer() || familyToAvoid != ConnectionFamily(*conn); }); - if (found != paths_.end() && peerToMatch == (*found)->getPeer()) - return found; - return paths_.end(); } Comm::ConnectionPointer -- 2.47.3