]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Happy Eyeballs: Do not wait for already exhausted spares (#509)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Thu, 21 Nov 2019 08:19:47 +0000 (08:19 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 21 Nov 2019 19:38:23 +0000 (19:38 +0000)
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

index 4cfbf205057bf49271727da48ad16c60cff85ecc..f7620134e2b704599abc2ab50166d67839c91e1e 100644 (file)
@@ -65,14 +65,11 @@ ResolvedPeers::findSpareOrNextPeer(const Comm::Connection &currentPeer)
     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