]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix CachePeer.cc:101 "!tcp_up" assertion after cache_peer death (#1962)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 13 Dec 2024 15:27:13 +0000 (15:27 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 15 Dec 2024 11:48:24 +0000 (11:48 +0000)
getFirstUpParent() could return a down (or otherwise disqualified)
cache_peer. Broken by 2023 commit 2e24d0b.

Refactored function structure to improve code quality, partially
addressing "use our return/reporting style" TODO in getDefaultParent().

src/neighbors.cc

index 4f704ae8360557b20c512712ed56e5d3c254a95b..6731dafd27e4aef37f74f8e16ce1cf8b3b3922b9 100644 (file)
@@ -282,10 +282,8 @@ getFirstUpParent(PeerSelector *ps)
     assert(ps);
     HttpRequest *request = ps->request;
 
-    CachePeer *p = nullptr;
-
     for (const auto &peer: CurrentCachePeers()) {
-        p = peer.get();
+        const auto p = peer.get();
 
         if (!neighborUp(p))
             continue;
@@ -296,11 +294,12 @@ getFirstUpParent(PeerSelector *ps)
         if (!peerHTTPOkay(p, ps))
             continue;
 
-        break;
+        debugs(15, 3, "returning " << *p);
+        return p;
     }
 
-    debugs(15, 3, "returning " << RawPointer(p).orNil());
-    return p;
+    debugs(15, 3, "none found");
+    return nullptr;
 }
 
 CachePeer *