PeerSelectState.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_PEERSELECTSTATE_H
10#define SQUID_PEERSELECTSTATE_H
11
12#include "AccessLogEntry.h"
13#include "acl/Checklist.h"
14#include "base/CbcPointer.h"
15#include "comm/forward.h"
16#include "hier_code.h"
17#include "ip/Address.h"
18#include "ipcache.h"
19#include "mem/forward.h"
20#include "PingData.h"
21#include "typedefs.h" /* for IRCB */
22
23class ErrorState;
24class HtcpReplyData;
25class HttpRequest;
26class icp_common_t;
27class StoreEntry;
28
29void peerSelectInit(void);
30
33{
34public:
35 ~PeerSelectionInitiator() override = default;
36
39
44
46 bool subscribed = false;
47
48 /* protected: */
53};
54
55class FwdServer;
56
60{
62
63public:
65 ~PeerSelector() override;
66
67 /* Dns::IpReceiver API */
68 void noteIp(const Ip::Address &ip) override;
69 void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override;
70 void noteLookup(const Dns::LookupDetails &details) override;
71
72 // Produce a URL for display identifying the transaction we are
73 // trying to locate a peer for.
74 const SBuf url() const;
75
78
80 bool wantsMoreDestinations() const;
81
83 void handlePath(const Comm::ConnectionPointer &path, FwdServer &fs);
84
86 void selectMore();
87
89 void startPingWaiting();
90
93
95 static void HandlePingTimeout(PeerSelector *);
96
100
101 void *peerCountMcastPeerXXX = nullptr;
102
104
105protected:
106 bool selectionAborted();
107
108 void handlePingTimeout();
109 void handleIcpReply(CachePeer*, const peer_t, icp_common_t *header);
111#if USE_HTCP
114#endif
115
116 int checkNetdbDirect();
117 void checkAlwaysDirectDone(const Acl::Answer answer);
118 void checkNeverDirectDone(const Acl::Answer answer);
119
120 void selectSomeNeighbor();
122 void selectSomeDirect();
123 void selectSomeParent();
124 void selectAllParents();
125 void selectPinned();
126
127 void addSelection(CachePeer*, const hier_code);
128
129 void resolveSelected();
130
134
135private:
138 int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
139 size_t foundPaths = 0;
141
143
144 /*
145 * Why are these Ip::Address instead of CachePeer *? Because a
146 * CachePeer structure can become invalid during the CachePeer selection
147 * phase, specifically after a reconfigure. Thus we need to lookup
148 * the CachePeer * based on the address when we are finally ready to
149 * reference the CachePeer structure.
150 */
151
153
155 /*
156 * ->hit can be CachePeer* because it should only be
157 * accessed during the thread when it is set
158 */
162
165
167};
168
169#endif /* SQUID_PEERSELECTSTATE_H */
170
void ACLCB(Acl::Answer, void *)
ACL checklist callback.
Definition: Checklist.h:19
void peerSelectInit(void)
Definition: peer_select.cc:922
void error(char *format,...)
an interface for receiving IP::Addresses from nbgethostbyname()
Definition: ipcache.h:195
encapsulates DNS lookup results
Definition: LookupDetails.h:23
Interface for those who need a list of peers to forward a request to.
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
virtual void noteDestination(Comm::ConnectionPointer path)=0
called when a new unique destination has been found
~PeerSelectionInitiator() override=default
virtual void noteDestinationsEnd(ErrorState *error)=0
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
Definition: peer_select.cc:335
Ip::Address closest_parent_miss
bool selectionAborted()
Definition: peer_select.cc:401
void selectAllParents()
Adds alive parents. Used as a last resort for never_direct.
Definition: peer_select.cc:867
PeerSelectionInitiator * interestedInitiator()
void handlePingTimeout()
Definition: peer_select.cc:897
FwdServer * servers
a linked list of (unresolved) selected peers
HttpRequest * request
Initiator initiator_
recipient of the destinations we select; use interestedInitiator() to access
ErrorState * lastError
static void HandlePingTimeout(PeerSelector *)
called when the given selector should stop expecting ICP ping responses
Definition: peer_select.cc:916
void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
Definition: peer_select.cc:542
Acl::Answer always_direct
void selectMore()
a single selection loop iteration: attempts to add more destinations
Definition: peer_select.cc:611
void startPingWaiting()
switches into the PING_WAITING state (and associated timeout monitoring)
Definition: peer_select.cc:263
void handleIcpParentMiss(CachePeer *, icp_common_t *)
Definition: peer_select.cc:928
void cancelPingTimeoutMonitoring()
terminates ICP ping timeout monitoring
Definition: peer_select.cc:272
int checkNetdbDirect()
Definition: peer_select.cc:568
CbcPointer< PeerSelectionInitiator > Initiator
Ip::Address first_parent_miss
void handlePath(const Comm::ConnectionPointer &path, FwdServer &fs)
processes a newly discovered/finalized path
const SBuf url() const
AccessLogEntry::Pointer al
info for the future access.log entry
bool wantsMoreDestinations() const
void checkNeverDirectDone(const Acl::Answer answer)
Definition: peer_select.cc:343
void checkAlwaysDirectDone(const Acl::Answer answer)
Definition: peer_select.cc:371
void handleHtcpReply(CachePeer *, const peer_t, HtcpReplyData *)
void * peerCountMcastPeerXXX
a hack to help peerCountMcastPeersStart()
ping_data ping
void handleIcpReply(CachePeer *, const peer_t, icp_common_t *header)
Definition: peer_select.cc:971
static ACLCB CheckNeverDirectDone
void addSelection(CachePeer *, const hier_code)
static ACLCB CheckAlwaysDirectDone
void noteLookup(const Dns::LookupDetails &details) override
Definition: peer_select.cc:502
void selectSomeDirect()
Adds a "direct" entry if the request can be forwarded to the origin server.
Definition: peer_select.cc:820
StoreEntry * entry
void noteIp(const Ip::Address &ip) override
Called when/if nbgethostbyname() discovers a new good IP address.
Definition: peer_select.cc:516
Acl::Answer never_direct
PeerSelector(PeerSelectionInitiator *)
void resolveSelected()
A single DNS resolution loop iteration: Converts selected FwdServer to IPs.
Definition: peer_select.cc:413
void selectSomeNeighbor()
Definition: peer_select.cc:733
void selectSomeParent()
Definition: peer_select.cc:833
const InstanceId< PeerSelector > id
unique identification in worker log
CachePeer * hit
void selectPinned()
Selects a pinned connection if it exists, is valid, and is allowed.
Definition: peer_select.cc:707
~PeerSelector() override
Definition: peer_select.cc:231
void selectSomeNeighborReplies()
Selects a neighbor (parent or sibling) based on ICP/HTCP replies.
Definition: peer_select.cc:789
size_t foundPaths
number of unique destinations identified so far
void handleHtcpParentMiss(CachePeer *, HtcpReplyData *)
static IRCB HandlePingReply
CBDATA_CHILD(PeerSelector)
ACLChecklist * acl_checklist
Definition: SBuf.h:94
ICP probing of cache_peers during peer selection.
Definition: PingData.h:26
peer_t
Definition: enums.h:27
hier_code
Definition: hier_code.h:12
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors