PeerSelectState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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 
22 class ErrorState;
23 class HtcpReplyData;
24 class HttpRequest;
25 class icp_common_t;
26 class StoreEntry;
27 
28 void peerSelectInit(void);
29 
32 {
33 public:
34  virtual ~PeerSelectionInitiator() = default;
35 
37  virtual void noteDestination(Comm::ConnectionPointer path) = 0;
38 
42  virtual void noteDestinationsEnd(ErrorState *error) = 0;
43 
45  bool subscribed = false;
46 
47  /* protected: */
52 };
53 
54 class FwdServer;
55 
59 {
61 
62 public:
64  virtual ~PeerSelector() override;
65 
66  /* Dns::IpReceiver API */
67  virtual void noteIp(const Ip::Address &ip) override;
68  virtual void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override;
69  virtual void noteLookup(const Dns::LookupDetails &details) override;
70 
71  // Produce a URL for display identifying the transaction we are
72  // trying to locate a peer for.
73  const SBuf url() const;
74 
77 
79  bool wantsMoreDestinations() const;
80 
83 
85  void selectMore();
86 
90 
91  void *peerCountMcastPeerXXX = nullptr;
92 
94 
95 protected:
96  bool selectionAborted();
97 
98  void handlePingTimeout();
99  void handleIcpReply(CachePeer*, const peer_t, icp_common_t *header);
101 #if USE_HTCP
104 #endif
105 
106  int checkNetdbDirect();
107  void checkAlwaysDirectDone(const allow_t answer);
108  void checkNeverDirectDone(const allow_t answer);
109 
110  void selectSomeNeighbor();
112  void selectSomeDirect();
113  void selectSomeParent();
114  void selectAllParents();
115  void selectPinned();
116 
117  void addSelection(CachePeer*, const hier_code);
118 
119  void resolveSelected();
120 
125 
126 private:
129  int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
130  size_t foundPaths = 0;
132 
134 
135  /*
136  * Why are these Ip::Address instead of CachePeer *? Because a
137  * CachePeer structure can become invalid during the CachePeer selection
138  * phase, specifically after a reconfigure. Thus we need to lookup
139  * the CachePeer * based on the address when we are finally ready to
140  * reference the CachePeer structure.
141  */
142 
144 
146  /*
147  * ->hit can be CachePeer* because it should only be
148  * accessed during the thread when it is set
149  */
153 
156 
158 };
159 
160 #endif /* SQUID_PEERSELECTSTATE_H */
161 
virtual void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
Definition: peer_select.cc:386
void peerSelectInit(void)
Definition: peer_select.cc:765
HttpRequest * request
size_t foundPaths
number of unique destinations identified so far
an interface for receiving IP::Addresses from nbgethostbyname()
Definition: ipcache.h:194
int checkNetdbDirect()
Definition: peer_select.cc:412
void checkNeverDirectDone(const allow_t answer)
Definition: peer_select.cc:201
virtual void noteLookup(const Dns::LookupDetails &details) override
Definition: peer_select.cc:349
ErrorState * lastError
void handleHtcpParentMiss(CachePeer *, HtcpReplyData *)
Definition: peer_select.cc:867
ping_data ping
void resolveSelected()
A single DNS resolution loop iteration: Converts selected FwdServer to IPs.
Definition: peer_select.cc:271
Definition: Acl.h:113
Definition: SBuf.h:86
virtual ~PeerSelector() override
Definition: peer_select.cc:102
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void error(char *format,...)
ACLChecklist * acl_checklist
FwdServer * servers
a linked list of (unresolved) selected peers
encapsulates DNS lookup results
Definition: LookupDetails.h:20
static EVH HandlePingTimeout
static ACLCB CheckNeverDirectDone
Interface for those who need a list of peers to forward a request to.
void checkAlwaysDirectDone(const allow_t answer)
Definition: peer_select.cc:229
const InstanceId< PeerSelector > id
unique identification in worker log
Ip::Address closest_parent_miss
allow_t always_direct
void handleHtcpReply(CachePeer *, const peer_t, HtcpReplyData *)
Definition: peer_select.cc:845
static IRCB HandlePingReply
CBDATA_CHILD(PeerSelector)
void addSelection(CachePeer *, const hier_code)
Definition: peer_select.cc:925
bool selectionAborted()
Definition: peer_select.cc:259
PeerSelectionInitiator * interestedInitiator()
Definition: peer_select.cc:980
StoreEntry * entry
bool wantsMoreDestinations() const
Definition: peer_select.cc:999
void EVH(void *)
Definition: event.h:19
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
void handlePingTimeout()
Definition: peer_select.cc:743
void handlePath(Comm::ConnectionPointer &path, FwdServer &fs)
processes a newly discovered/finalized path
void handleIcpParentMiss(CachePeer *, icp_common_t *)
Definition: peer_select.cc:771
virtual void noteDestination(Comm::ConnectionPointer path)=0
called when a new unique destination has been found
PeerSelector(PeerSelectionInitiator *)
Definition: peer_select.cc:947
CachePeer * hit
void selectSomeNeighbor()
Definition: peer_select.cc:577
void IRCB(CachePeer *, peer_t, AnyP::ProtocolType, void *, void *data)
Definition: typedefs.h:22
void selectSomeNeighborReplies()
Selects a neighbor (parent or sibling) based on ICP/HTCP replies.
Definition: peer_select.cc:635
Initiator initiator_
recipient of the destinations we select; use interestedInitiator() to access
AccessLogEntry::Pointer al
info for the future access.log entry
hier_code
Definition: hier_code.h:12
void handleIcpReply(CachePeer *, const peer_t, icp_common_t *header)
Definition: peer_select.cc:812
virtual void noteDestinationsEnd(ErrorState *error)=0
void selectAllParents()
Adds alive parents. Used as a last resort for never_direct.
Definition: peer_select.cc:713
void selectSomeParent()
Definition: peer_select.cc:679
Ip::Address first_parent_miss
peer_t
Definition: enums.h:27
CbcPointer< PeerSelectionInitiator > Initiator
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
Definition: peer_select.cc:193
allow_t never_direct
void ACLCB(allow_t, void *)
ACL checklist callback.
Definition: Checklist.h:19
static ACLCB CheckAlwaysDirectDone
void selectMore()
a single selection loop iteration: attempts to add more destinations
Definition: peer_select.cc:455
virtual void noteIp(const Ip::Address &ip) override
Called when/if nbgethostbyname() discovers a new good IP address.
Definition: peer_select.cc:363
void selectPinned()
Selects a pinned connection if it exists, is valid, and is allowed.
Definition: peer_select.cc:550
const SBuf url() const
Definition: peer_select.cc:966
void selectSomeDirect()
Adds a &quot;direct&quot; entry if the request can be forwarded to the origin server.
Definition: peer_select.cc:666
virtual ~PeerSelectionInitiator()=default
void * peerCountMcastPeerXXX
a hack to help peerCountMcastPeersStart()

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors