char *digest_url = nullptr;
#endif
- int tcp_up = 0; /* 0 if a connect() fails */
+ /// The number of failures sufficient to stop selecting this cache_peer. All
+ /// cache_peer selection algorithms skip cache_peers with 0 tcp_up values.
+ /// The initial 0 value prevents unprobed cache_peers from being selected.
+ int tcp_up = 0;
+
/// whether to do another TCP probe after current TCP probes
bool reprobe = false;
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 3600.0, 1);
}
-static void
-peerConnectFailedSilent(CachePeer * p)
+// TODO: Move to CachePeer::noteFailure() or similar.
+// TODO: Require callers to detail failures instead of using one (and often
+// misleading!) "TCP" label for all of them.
+void
+peerConnectFailed(CachePeer * const p)
{
p->stats.last_connect_failure = squid_curtime;
+ if (p->tcp_up > 0)
+ --p->tcp_up;
- if (!p->tcp_up) {
- debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port <<
- " dead");
- return;
- }
+ // TODO: Report peer name. Same-addresses peers often have different names.
- -- p->tcp_up;
+ const auto consideredAliveByAdmin = p->stats.logged_state == PEER_ALIVE;
+ const auto level = consideredAliveByAdmin ? DBG_IMPORTANT : 2;
+ debugs(15, level, "ERROR: TCP connection to " << p->host << "/" << p->http_port << " failed");
- if (!p->tcp_up) {
- debugs(15, DBG_IMPORTANT, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name);
- p->stats.logged_state = PEER_DEAD;
+ if (consideredAliveByAdmin) {
+ if (!p->tcp_up) {
+ debugs(15, DBG_IMPORTANT, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name);
+ p->stats.logged_state = PEER_DEAD;
+ } else {
+ debugs(15, 2, "additional failures needed to mark this cache_peer DEAD: " << p->tcp_up);
+ }
+ } else {
+ assert(!p->tcp_up);
+ debugs(15, 2, "cache_peer " << p->host << "/" << p->http_port << " is still DEAD");
}
}
-void
-peerConnectFailed(CachePeer *p)
-{
- debugs(15, DBG_IMPORTANT, "ERROR: TCP connection to " << p->host << "/" << p->http_port << " failed");
- peerConnectFailedSilent(p);
-}
-
void
peerConnectSucceded(CachePeer * p)
{
if (status == Comm::OK) {
peerConnectSucceded(p);
} else {
- peerConnectFailedSilent(p);
+ peerConnectFailed(p);
}
-- p->testing_now;