From e9eb59001897df446a89dfaf849554798b65c967 Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Fri, 13 Dec 2024 15:27:13 +0000 Subject: [PATCH] Fix CachePeer.cc:101 "!tcp_up" assertion after cache_peer death (#1962) 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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/neighbors.cc b/src/neighbors.cc index 4f704ae8360..6731dafd27e 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -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 *