#include <PeerSelectState.h>

Inheritance diagram for PeerSelector:
Collaboration diagram for PeerSelector:

Public Member Functions

 PeerSelector (PeerSelectionInitiator *)
 
virtual ~PeerSelector () override
 
virtual void noteIp (const Ip::Address &ip) override
 Called when/if nbgethostbyname() discovers a new good IP address. More...
 
virtual void noteIps (const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
 
virtual void noteLookup (const Dns::LookupDetails &details) override
 
const SBuf url () const
 
PeerSelectionInitiatorinterestedInitiator ()
 
bool wantsMoreDestinations () const
 
void handlePath (Comm::ConnectionPointer &path, FwdServer &fs)
 processes a newly discovered/finalized path More...
 
void selectMore ()
 a single selection loop iteration: attempts to add more destinations More...
 
virtual void * toCbdata ()=0
 

Public Attributes

HttpRequestrequest
 
AccessLogEntry::Pointer al
 info for the future access.log entry More...
 
StoreEntryentry
 
void * peerCountMcastPeerXXX = nullptr
 a hack to help peerCountMcastPeersStart() More...
 
ping_data ping
 

Protected Member Functions

bool selectionAborted ()
 
void handlePingTimeout ()
 
void handleIcpReply (CachePeer *, const peer_t, icp_common_t *header)
 
void handleIcpParentMiss (CachePeer *, icp_common_t *)
 
void handleHtcpParentMiss (CachePeer *, HtcpReplyData *)
 
void handleHtcpReply (CachePeer *, const peer_t, HtcpReplyData *)
 
int checkNetdbDirect ()
 
void checkAlwaysDirectDone (const allow_t answer)
 
void checkNeverDirectDone (const allow_t answer)
 
void selectSomeNeighbor ()
 
void selectSomeNeighborReplies ()
 Selects a neighbor (parent or sibling) based on ICP/HTCP replies. More...
 
void selectSomeDirect ()
 Adds a "direct" entry if the request can be forwarded to the origin server. More...
 
void selectSomeParent ()
 
void selectAllParents ()
 Adds alive parents. Used as a last resort for never_direct. More...
 
void selectPinned ()
 Selects a pinned connection if it exists, is valid, and is allowed. More...
 
void addSelection (CachePeer *, const hier_code)
 
void resolveSelected ()
 A single DNS resolution loop iteration: Converts selected FwdServer to IPs. More...
 

Static Protected Attributes

static IRCB HandlePingReply
 
static ACLCB CheckAlwaysDirectDone
 
static ACLCB CheckNeverDirectDone
 
static EVH HandlePingTimeout
 

Private Types

typedef CbcPointer
< PeerSelectionInitiator
Initiator
 

Private Member Functions

 CBDATA_CHILD (PeerSelector)
 

Private Attributes

allow_t always_direct
 
allow_t never_direct
 
int direct
 
size_t foundPaths = 0
 number of unique destinations identified so far More...
 
ErrorStatelastError
 
FwdServerservers
 a linked list of (unresolved) selected peers More...
 
Ip::Address first_parent_miss
 
Ip::Address closest_parent_miss
 
CachePeerhit
 
peer_t hit_type
 
ACLChecklistacl_checklist
 
Initiator initiator_
 recipient of the destinations we select; use interestedInitiator() to access More...
 
const InstanceId< PeerSelectorid
 unique identification in worker log More...
 

Detailed Description

Finds peer (including origin server) IPs for forwarding a single request. Gives PeerSelectionInitiator each found destination, in the right order.

Definition at line 58 of file PeerSelectState.h.

Member Typedef Documentation

Definition at line 154 of file PeerSelectState.h.

Constructor & Destructor Documentation

PeerSelector::PeerSelector ( PeerSelectionInitiator initiator)
explicit

Definition at line 947 of file peer_select.cc.

Member Function Documentation

void PeerSelector::addSelection ( CachePeer peer,
const hier_code  code 
)
protected
PeerSelector::CBDATA_CHILD ( PeerSelector  )
private
void PeerSelector::checkAlwaysDirectDone ( const allow_t  answer)
protected

if always_direct says YES, do that.

Definition at line 229 of file peer_select.cc.

References ACCESS_ALLOWED, ACCESS_AUTH_REQUIRED, ACCESS_DENIED, ACCESS_DUNNO, acl_checklist, always_direct, DBG_IMPORTANT, debugs, direct, DIRECT_YES, DirectStr, and selectMore().

void PeerSelector::checkNeverDirectDone ( const allow_t  answer)
protected

if never_direct says YES, do that.

Definition at line 201 of file peer_select.cc.

References ACCESS_ALLOWED, ACCESS_AUTH_REQUIRED, ACCESS_DENIED, ACCESS_DUNNO, acl_checklist, DBG_IMPORTANT, debugs, direct, DIRECT_NO, DirectStr, never_direct, and selectMore().

void PeerSelector::handleHtcpReply ( CachePeer p,
const peer_t  type,
HtcpReplyData htcp 
)
protected
void PeerSelector::handlePingTimeout ( )
protected
PeerSelectionInitiator * PeerSelector::interestedInitiator ( )
Returns
valid/interested peer initiator or nil

Definition at line 980 of file peer_select.cc.

References debugs, initiator_, and CbcPointer< Cbc >::valid().

Referenced by handlePath(), resolveSelected(), and selectionAborted().

void PeerSelector::noteIps ( const Dns::CachedIps ips,
const Dns::LookupDetails details 
)
overridevirtual

Called when nbgethostbyname() fully resolves the name. The ips may contain both bad and good IP addresses, but each good IP (if any) is guaranteed to had been previously reported via noteIp().

Implements Dns::IpReceiver.

Definition at line 386 of file peer_select.cc.

References FwdServer::_peer, FwdServer::code, debugs, ErrorState::dnsError, ERR_DNS_FAIL, Dns::LookupDetails::error, HIER_DIRECT, CachePeer::host, AnyP::Uri::host(), lastError, FwdServer::next, NULL, request, resolveSelected(), Http::scServiceUnavailable, selectionAborted(), servers, HttpRequest::url, and CbcPointer< Cbc >::valid().

void PeerSelector::noteLookup ( const Dns::LookupDetails )
overridevirtual

Called when/if nbgethostbyname() completes a single DNS lookup if called, called before all the noteIp() calls for that DNS lookup.

Reimplemented from Dns::IpReceiver.

Definition at line 349 of file peer_select.cc.

References HttpRequest::recordLookup(), request, selectionAborted(), and wantsMoreDestinations().

void PeerSelector::selectAllParents ( )
protected
bool PeerSelector::selectionAborted ( )
protected
Returns
true (after destroying "this") if the peer initiator is gone
false (without side effects) otherwise

Definition at line 259 of file peer_select.cc.

References debugs, and interestedInitiator().

Referenced by handlePingTimeout(), noteIp(), noteIps(), noteLookup(), resolveSelected(), and selectMore().

void PeerSelector::selectSomeDirect ( )
protected
void PeerSelector::selectSomeNeighbor ( )
protected
virtual void* CbdataParent::toCbdata ( )
pure virtualinherited
const SBuf PeerSelector::url ( ) const
bool PeerSelector::wantsMoreDestinations ( ) const
Returns
whether the initiator may use more destinations

Definition at line 999 of file peer_select.cc.

References Config, SquidConfig::forward_max_tries, foundPaths, and type.

Referenced by noteIp(), noteLookup(), and resolveSelected().

Member Data Documentation

ACLChecklist* PeerSelector::acl_checklist
private
AccessLogEntry::Pointer PeerSelector::al

Definition at line 88 of file PeerSelectState.h.

Referenced by peerAllowedToUse(), and selectMore().

allow_t PeerSelector::always_direct
private

Definition at line 127 of file PeerSelectState.h.

Referenced by checkAlwaysDirectDone(), handlePath(), resolveSelected(), and selectMore().

void PeerSelector::CheckAlwaysDirectDone
staticprotected

Definition at line 122 of file PeerSelectState.h.

Referenced by selectMore().

void PeerSelector::CheckNeverDirectDone
staticprotected

Definition at line 123 of file PeerSelectState.h.

Referenced by selectMore().

Ip::Address PeerSelector::closest_parent_miss
private
Ip::Address PeerSelector::first_parent_miss
private
size_t PeerSelector::foundPaths = 0
private

Definition at line 130 of file PeerSelectState.h.

Referenced by handlePath(), resolveSelected(), and wantsMoreDestinations().

void PeerSelector::HandlePingReply
staticprotected

Definition at line 121 of file PeerSelectState.h.

Referenced by selectSomeNeighbor().

void PeerSelector::HandlePingTimeout
staticprotected

Definition at line 124 of file PeerSelectState.h.

Referenced by selectSomeNeighbor(), and ~PeerSelector().

CachePeer* PeerSelector::hit
private

Definition at line 150 of file PeerSelectState.h.

Referenced by handleHtcpReply(), handleIcpReply(), and selectSomeNeighborReplies().

peer_t PeerSelector::hit_type
private

Definition at line 151 of file PeerSelectState.h.

Referenced by handleHtcpReply(), handleIcpReply(), and selectSomeNeighborReplies().

const InstanceId<PeerSelector> PeerSelector::id
private

Definition at line 157 of file PeerSelectState.h.

Initiator PeerSelector::initiator_
private

Definition at line 155 of file PeerSelectState.h.

Referenced by interestedInitiator().

ErrorState* PeerSelector::lastError
private

Definition at line 131 of file PeerSelectState.h.

Referenced by noteIps(), resolveSelected(), and ~PeerSelector().

allow_t PeerSelector::never_direct
private

Definition at line 128 of file PeerSelectState.h.

Referenced by checkNeverDirectDone(), handlePath(), resolveSelected(), and selectMore().

void* PeerSelector::peerCountMcastPeerXXX = nullptr

Definition at line 91 of file PeerSelectState.h.

FwdServer* PeerSelector::servers
private

Definition at line 133 of file PeerSelectState.h.

Referenced by addSelection(), noteIp(), noteIps(), resolveSelected(), and ~PeerSelector().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors