98 os <<
'/' << *fsd.
peer;
171 const auto selector =
selectors.begin()->second;
172 CallBack(selector->al, [selector,
this] {
173 selector->ping.monitorRegistration = npos();
174 AsyncCall::Pointer callback = asyncCall(44, 4,
"PeerSelector::HandlePingTimeout",
175 cbdataDialer(PeerSelector::HandlePingTimeout, selector));
176 ScheduleCallHere(callback);
197 const auto position =
selectors.emplace(deadline, selector);
293 debugs(44, 3,
"counted " << n <<
" neighbors");
305 debugs(44, 3, *entry <<
' ' << entry->
url());
311 selector->request = request;
315 selector->entry = entry;
324 selector->entry->lock(
"peerSelect");
326 selector->selectMore();
352 debugs(44,
DBG_IMPORTANT,
"WARNING: never_direct resulted in " << answer <<
". Username ACLs are not reliable here.");
379 debugs(44,
DBG_IMPORTANT,
"WARNING: always_direct resulted in " << answer <<
". Username ACLs are not reliable here.");
399 debugs(44, 3,
"Aborting peer selection: Initiator gone or lost interest.");
422 if (isIntercepted && useOriginalDst && choseDirect) {
454 debugs(44, 2,
"Find IP destination for: " <<
url() <<
"' via " << host);
483 debugs(44, 3,
"forgetting the last error");
489 initiator->noteDestinationsEnd(
lastError);
574 debugs(44, 3,
"MY RTT = " << myrtt <<
" msec");
582 debugs(44, 3,
"MY hops = " << myhops);
650 if (
entry ==
nullptr) {
746 debugs(44, 3,
"Doing ICP pings");
863 const auto p = peer.get();
926 rtt = header->
pad & 0xFFFF;
927 int hops = (header->
pad >> 16) & 0xFFFF;
929 if (rtt > 0 && rtt < 0xFFFF)
966#if USE_CACHE_DIGESTS && 0
997 debugs(44, 3, (htcp->
hit ?
"HIT" :
"MISS") <<
' ' <<
url());
1073 debugs(44,
DBG_IMPORTANT,
"ERROR: ignoring an ICP reply with unknown protocol " << proto);
1080 auto **serversTail = &
servers;
1081 while (
const auto server = *serversTail) {
1094 serversTail = &
server->next;
1098 *serversTail =
new FwdServer(peer, code);
1109 first_parent_miss(),
1110 closest_parent_miss(),
1113 initiator_(initiator)
1127 static const SBuf noUrl(
"[no URL]");
1138 debugs(44, 3,
id <<
" initiator gone");
1142 if (!initiator->subscribed) {
1143 debugs(44, 3,
id <<
" initiator lost interest");
1154 return maxCount >= 0 && foundPaths < static_cast<size_t>(maxCount);
1168 debugs(44, 2,
id <<
" found " << path <<
", destination #" <<
foundPaths <<
" for " <<
url());
1179 initiator->noteDestination(path);
1187 n_replies_expected(0),
1203 timeval timeInterval;
1204 timeInterval.tv_sec =
timeout / 1000;
1205 timeInterval.tv_usec = (
timeout % 1000) * 1000;
#define MEMPROXY_CLASS(CLASS)
const CachePeers & CurrentCachePeers()
void CallBack(const CodeContext::Pointer &callbackContext, Fun &&callback)
void getOutgoingAddress(HttpRequest *request, const Comm::ConnectionPointer &conn)
#define InstanceIdDefinitions(...)
convenience macro to instantiate Class-specific stuff in .cc files
WaitingPeerSelectors::iterator WaitingPeerSelectorPosition
std::multimap< timeval, PeerSelector *, std::less< timeval >, PoolingAllocator< WaitingPeerSelector > > WaitingPeerSelectors
waiting PeerSelector objects, ordered by their absolute deadlines
static char server[MAXLINE]
CachePeer * carpSelectParent(PeerSelector *ps)
#define CBDATA_CLASS_INIT(type)
static MakingPointer Make(const acl_access *a, HttpRequest *r)
static void NonBlockingCheck(MakingPointer &&p, ACLCB *cb, void *data)
AnyP::UriScheme const & getScheme() const
void port(const Port p)
reset authority port subcomponent
void host(const char *src)
struct CachePeer::@20 options
Cbc * valid() const
was set and is valid
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
void setPeer(CachePeer *p)
struct ConnStateData::@29 pinning
CachePeer * pinnedPeer() const
bool peerAccessDenied
cache_peer_access denied pinned connection reuse
encapsulates DNS lookup results
const std::optional< SBuf > error
error message (if any)
std::optional< SBuf > dnsError
DNS lookup error message.
CbcPointer< CachePeer > _peer
FwdServer(CachePeer *p, hier_code c)
struct timeval peer_select_start
struct HtcpReplyData::cto_t cto
void recordLookup(const Dns::LookupDetails &detail)
CbcPointer< ConnStateData > clientConnectionManager
ConnStateData * pinnedConnection()
AnyP::Uri url
the request URI
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
unsigned short port() const
a helper class to report a selected destination (for debugging)
PeerSelectionDumper(const PeerSelector *const aSelector, const CachePeer *const aPeer, const hier_code aCode)
const CachePeer *const peer
successful selection info
const PeerSelector *const selector
selection parameters
const hier_code code
selection algorithm
Interface for those who need a list of peers to forward a request to.
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
void monitor(PeerSelector *)
registers the given selector to be notified about the IPC ping timeout
static void NoteWaitOver(void *monitor)
PeerSelectorPingMonitor::noteWaitOver() wrapper.
void abortWaiting()
undoes an earlier startWaiting() call
WaitingPeerSelectorPosition npos()
void startWaiting()
schedules a single event to represent all waiting selectors
void forget(PeerSelector *)
removes a PeerSelector from the waiting list
void noteWaitOver()
calls back all ready PeerSelectors and continues to wait for others
WaitingPeerSelectors selectors
Ip::Address closest_parent_miss
void selectAllParents()
Adds alive parents. Used as a last resort for never_direct.
PeerSelectionInitiator * interestedInitiator()
FwdServer * servers
a linked list of (unresolved) selected peers
Initiator initiator_
recipient of the destinations we select; use interestedInitiator() to access
static void HandlePingTimeout(PeerSelector *)
called when the given selector should stop expecting ICP ping responses
void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
Acl::Answer always_direct
void selectMore()
a single selection loop iteration: attempts to add more destinations
void startPingWaiting()
switches into the PING_WAITING state (and associated timeout monitoring)
void handleIcpParentMiss(CachePeer *, icp_common_t *)
void cancelPingTimeoutMonitoring()
terminates ICP ping timeout monitoring
Ip::Address first_parent_miss
void handlePath(const Comm::ConnectionPointer &path, FwdServer &fs)
processes a newly discovered/finalized path
AccessLogEntry::Pointer al
info for the future access.log entry
bool wantsMoreDestinations() const
void checkNeverDirectDone(const Acl::Answer answer)
void checkAlwaysDirectDone(const Acl::Answer answer)
void handleHtcpReply(CachePeer *, const peer_t, HtcpReplyData *)
void handleIcpReply(CachePeer *, const peer_t, icp_common_t *header)
static ACLCB CheckNeverDirectDone
void addSelection(CachePeer *, const hier_code)
static ACLCB CheckAlwaysDirectDone
void noteLookup(const Dns::LookupDetails &details) override
void selectSomeDirect()
Adds a "direct" entry if the request can be forwarded to the origin server.
void noteIp(const Ip::Address &ip) override
Called when/if nbgethostbyname() discovers a new good IP address.
PeerSelector(PeerSelectionInitiator *)
void resolveSelected()
A single DNS resolution loop iteration: Converts selected FwdServer to IPs.
void selectSomeNeighbor()
void selectPinned()
Selects a pinned connection if it exists, is valid, and is allowed.
void selectSomeNeighborReplies()
Selects a neighbor (parent or sibling) based on ICP/HTCP replies.
size_t foundPaths
number of unique destinations identified so far
void handleHtcpParentMiss(CachePeer *, HtcpReplyData *)
static IRCB HandlePingReply
bool interceptTproxy
Set for requests handled by a "tproxy" port.
Comm::ConnectionPointer clientConnection
int nonhierarchical_direct
struct SquidConfig::@90 onoff
struct SquidConfig::@91 accessList
acl_access * AlwaysDirect
int unlock(const char *context)
ping_status_t ping_status
icp_opcode getOpCode() const
WaitingPeerSelectorPosition monitorRegistration
maintained by PeerSelectorPingMonitor
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_TEST(flag, bit)
@ PING_WAITING
Sent ICP queries to peers and still awaiting responses.
@ PING_NONE
Has not considered whether to send ICP queries to peers yet.
void eventDelete(EVH *func, void *arg)
void eventAdd(const char *name, EVH *func, void *arg, double when, int weight, bool cbdata)
int neighbors_do_private_keys
const char * hier_code_str[]
void HTTPMSGUNLOCK(M *&a)
void HTTPMSGLOCK(Http::Message *a)
const char * icp_opcode_str[]
void nbgethostbyname(const char *name, const CbcPointer< IpReceiver > &receiver)
initiate an (often) asynchronous DNS lookup; the receiver gets the results
code related to Squid Instance and PID file management
void peerNoteDigestLookup(HttpRequest *request, CachePeer *p, lookup_t lookup)
CachePeer * getFirstUpParent(PeerSelector *ps)
CachePeer * whichPeer(const Ip::Address &from)
int neighborsCount(PeerSelector *ps)
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
CachePeer * getDefaultParent(PeerSelector *ps)
CachePeer * getRoundRobinParent(PeerSelector *ps)
bool peerAllowedToUse(const CachePeer *, PeerSelector *)
peer_t neighborType(const CachePeer *p, const AnyP::Uri &url)
int neighborsUdpPing(HttpRequest *request, StoreEntry *entry, IRCB *callback, PeerSelector *ps, int *exprep, int *timeout)
CachePeer * neighborsDigestSelect(PeerSelector *ps)
lookup_t peerDigestLookup(CachePeer *p, PeerSelector *ps)
CachePeer * getWeightedRoundRobinParent(PeerSelector *ps)
int netdbHostHops(const char *host)
int netdbHostRtt(const char *host)
void netdbUpdatePeer(const AnyP::Uri &url, CachePeer *e, int irtt, int ihops)
CachePeer * netdbClosestParent(PeerSelector *ps)
static int peerSelectIcpPing(PeerSelector *ps, int direct, StoreEntry *entry)
static struct @71 PeerStats
void peerSelectInit(void)
bool peerAllowedToUse(const CachePeer *, PeerSelector *)
static const char * DirectStr[]
static void peerSelect(PeerSelectionInitiator *initiator, HttpRequest *request, AccessLogEntry::Pointer const &al, StoreEntry *entry)
static std::ostream & operator<<(std::ostream &os, const PeerSelectionDumper &fsd)
prints PeerSelectionDumper (for debugging)
static PeerSelectorPingMonitor & PingMonitor()
monitors all PeerSelector ICP ping timeouts
CachePeer * peerSourceHashSelectParent(PeerSelector *ps)
CachePeer * peerUserHashSelectParent(PeerSelector *ps)
time_t struct timeval struct timeval struct timeval struct timeval const struct timeval const &STUB void tvAdd(struct timeval &, struct timeval const &, struct timeval const &) STUB void tvAssignAdd(struct timeval &
double tvSubDsec(struct timeval t1, struct timeval t2)
struct timeval current_time
the current UNIX time in timeval {seconds, microseconds} format
int tvSubMsec(struct timeval t1, struct timeval t2)