PeerSelectState.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 HttpRequest;
23 class StoreEntry;
24 class ErrorState;
25 
26 void peerSelectInit(void);
27 
30 {
31 public:
32  virtual ~PeerSelectionInitiator() = default;
33 
35  virtual void noteDestination(Comm::ConnectionPointer path) = 0;
36 
40  virtual void noteDestinationsEnd(ErrorState *error) = 0;
41 
43  bool subscribed = false;
44 
45  /* protected: */
50 };
51 
52 class FwdServer;
53 
55 {
57 
58 public:
59  explicit ps_state(PeerSelectionInitiator *initiator);
60  virtual ~ps_state() override;
61 
62  /* Dns::IpReceiver API */
63  virtual void noteIp(const Ip::Address &ip) override;
64  virtual void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override;
65  virtual void noteLookup(const Dns::LookupDetails &details) override;
66 
67  // Produce a URL for display identifying the transaction we are
68  // trying to locate a peer for.
69  const SBuf url() const;
70 
73 
75  bool wantsMoreDestinations() const;
76 
79 
85  int direct; // TODO: fold always_direct/never_direct/prefer_direct into this now that ACL can do a multi-state result.
86  size_t foundPaths = 0;
87  void *peerCountMcastPeerXXX = nullptr;
89 
91 
92  /*
93  * Why are these Ip::Address instead of CachePeer *? Because a
94  * CachePeer structure can become invalid during the CachePeer selection
95  * phase, specifically after a reconfigure. Thus we need to lookup
96  * the CachePeer * based on the address when we are finally ready to
97  * reference the CachePeer structure.
98  */
99 
101 
103  /*
104  * ->hit can be CachePeer* because it should only be
105  * accessed during the thread when it is set
106  */
111 
113 
114 private:
115 
118 };
119 
120 #endif /* SQUID_PEERSELECTSTATE_H */
121 
virtual void noteIp(const Ip::Address &ip) override
Called when/if nbgethostbyname() discovers a new good IP address.
Definition: peer_select.cc:341
an interface for receiving IP::Addresses from nbgethostbyname()
Definition: ipcache.h:194
allow_t never_direct
ACLChecklist * acl_checklist
ErrorState * lastError
Definition: Acl.h:113
Definition: SBuf.h:87
virtual void noteIps(const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
Definition: peer_select.cc:364
void handlePath(Comm::ConnectionPointer &path, FwdServer &fs)
processes a newly discovered/finalized path
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void error(char *format,...)
encapsulates DNS lookup results
Definition: LookupDetails.h:20
FwdServer * servers
temporary linked list of peers we will pass back.
Interface for those who need a list of peers to forward a request to.
bool subscribed
whether noteDestination() and noteDestinationsEnd() calls are allowed
StoreEntry * entry
const InstanceId< ps_state > id
unique identification in worker log
virtual void noteDestination(Comm::ConnectionPointer path)=0
called when a new unique destination has been found
CbcPointer< PeerSelectionInitiator > Initiator
ps_state(PeerSelectionInitiator *initiator)
Definition: peer_select.cc:941
size_t foundPaths
number of unique destinations identified so far
virtual ~ps_state() override
Definition: peer_select.cc:94
void * peerCountMcastPeerXXX
a hack to help peerCountMcastPeersStart()
CBDATA_CHILD(ps_state)
Initiator initiator_
recipient of the destinations we select; use interestedInitiator() to access
void peerSelectInit(void)
Definition: peer_select.cc:766
Ip::Address first_parent_miss
PeerSelectionInitiator * interestedInitiator()
Definition: peer_select.cc:974
virtual void noteDestinationsEnd(ErrorState *error)=0
ping_data ping
HttpRequest * request
peer_t
Definition: enums.h:27
peer_t hit_type
const SBuf url() const
Definition: peer_select.cc:960
void startSelectingDestinations(HttpRequest *request, const AccessLogEntry::Pointer &ale, StoreEntry *entry)
Definition: peer_select.cc:182
AccessLogEntry::Pointer al
info for the future access.log entry
Ip::Address closest_parent_miss
CachePeer * hit
allow_t always_direct
virtual ~PeerSelectionInitiator()=default
bool wantsMoreDestinations() const
Definition: peer_select.cc:993
virtual void noteLookup(const Dns::LookupDetails &details) override
Definition: peer_select.cc:327

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors