#include <PeerSelectState.h>

Inheritance diagram for PeerSelector:
Collaboration diagram for PeerSelector:

Public Member Functions

 PeerSelector (PeerSelectionInitiator *)
 
 ~PeerSelector () override
 
void noteIp (const Ip::Address &ip) override
 Called when/if nbgethostbyname() discovers a new good IP address. More...
 
void noteIps (const Dns::CachedIps *ips, const Dns::LookupDetails &details) override
 
void noteLookup (const Dns::LookupDetails &details) override
 
const SBuf url () const
 
PeerSelectionInitiatorinterestedInitiator ()
 
bool wantsMoreDestinations () const
 
void handlePath (const 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...
 
void startPingWaiting ()
 switches into the PING_WAITING state (and associated timeout monitoring) More...
 
void cancelPingTimeoutMonitoring ()
 terminates ICP ping timeout monitoring More...
 
virtual void * toCbdata ()=0
 

Static Public Member Functions

static void HandlePingTimeout (PeerSelector *)
 called when the given selector should stop expecting ICP ping responses More...
 

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 Acl::Answer answer)
 
void checkNeverDirectDone (const Acl::Answer 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
 

Private Types

typedef CbcPointer< PeerSelectionInitiatorInitiator
 

Private Member Functions

 CBDATA_CHILD (PeerSelector)
 
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() More...
 

Private Attributes

Acl::Answer always_direct
 
Acl::Answer 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 59 of file PeerSelectState.h.

Member Typedef Documentation

◆ Initiator

Definition at line 163 of file PeerSelectState.h.

Constructor & Destructor Documentation

◆ PeerSelector()

PeerSelector::PeerSelector ( PeerSelectionInitiator initiator)
explicit

Definition at line 1110 of file peer_select.cc.

◆ ~PeerSelector()

Member Function Documentation

◆ addSelection()

void PeerSelector::addSelection ( CachePeer peer,
const hier_code  code 
)
protected

◆ cancelPingTimeoutMonitoring()

void PeerSelector::cancelPingTimeoutMonitoring ( )

Definition at line 272 of file peer_select.cc.

References PeerSelectorPingMonitor::forget(), and PingMonitor().

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

◆ CBDATA_CHILD()

PeerSelector::CBDATA_CHILD ( PeerSelector  )
private

◆ checkAlwaysDirectDone()

void PeerSelector::checkAlwaysDirectDone ( const Acl::Answer  answer)
protected

if always_direct says YES, do that.

Definition at line 371 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().

◆ checkNetdbDirect()

◆ checkNeverDirectDone()

void PeerSelector::checkNeverDirectDone ( const Acl::Answer  answer)
protected

if never_direct says YES, do that.

Definition at line 343 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().

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ handleHtcpParentMiss()

◆ handleHtcpReply()

void PeerSelector::handleHtcpReply ( CachePeer p,
const peer_t  type,
HtcpReplyData htcp 
)
protected

◆ handleIcpParentMiss()

◆ handleIcpReply()

◆ handlePath()

◆ handlePingTimeout()

void PeerSelector::handlePingTimeout ( )
protected

◆ HandlePingTimeout()

void PeerSelector::HandlePingTimeout ( PeerSelector selector)
static

Definition at line 916 of file peer_select.cc.

References handlePingTimeout().

◆ interestedInitiator()

PeerSelectionInitiator * PeerSelector::interestedInitiator ( )
Returns
valid/interested peer initiator or nil

Definition at line 1143 of file peer_select.cc.

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

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

◆ noteIp()

◆ noteIps()

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(). When no IPs were obtained, ips is nil.

Implements Dns::IpReceiver.

Definition at line 542 of file peer_select.cc.

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

◆ noteLookup()

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 502 of file peer_select.cc.

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

◆ resolveSelected()

◆ selectAllParents()

void PeerSelector::selectAllParents ( )
protected

◆ selectionAborted()

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

Definition at line 401 of file peer_select.cc.

References debugs, and interestedInitiator().

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

◆ selectMore()

◆ selectPinned()

◆ selectSomeDirect()

void PeerSelector::selectSomeDirect ( )
protected

◆ selectSomeNeighbor()

void PeerSelector::selectSomeNeighbor ( )
protected

◆ selectSomeNeighborReplies()

◆ selectSomeParent()

◆ startPingWaiting()

void PeerSelector::startPingWaiting ( )

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ url()

const SBuf PeerSelector::url ( ) const

◆ wantsMoreDestinations()

bool PeerSelector::wantsMoreDestinations ( ) const
Returns
whether the initiator may use more destinations

Definition at line 1162 of file peer_select.cc.

References Config, and SquidConfig::forward_max_tries.

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

Member Data Documentation

◆ acl_checklist

ACLChecklist* PeerSelector::acl_checklist
private

◆ al

AccessLogEntry::Pointer PeerSelector::al

Definition at line 98 of file PeerSelectState.h.

Referenced by noteIps(), peerAllowedToUse(), and selectMore().

◆ always_direct

Acl::Answer PeerSelector::always_direct
private

Definition at line 136 of file PeerSelectState.h.

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

◆ CheckAlwaysDirectDone

void PeerSelector::CheckAlwaysDirectDone
staticprotected

Definition at line 132 of file PeerSelectState.h.

Referenced by selectMore().

◆ CheckNeverDirectDone

void PeerSelector::CheckNeverDirectDone
staticprotected

Definition at line 133 of file PeerSelectState.h.

Referenced by selectMore().

◆ closest_parent_miss

Ip::Address PeerSelector::closest_parent_miss
private

◆ direct

◆ entry

◆ first_parent_miss

Ip::Address PeerSelector::first_parent_miss
private

◆ foundPaths

size_t PeerSelector::foundPaths = 0
private

Definition at line 139 of file PeerSelectState.h.

Referenced by handlePath(), and resolveSelected().

◆ HandlePingReply

void PeerSelector::HandlePingReply
staticprotected

Definition at line 131 of file PeerSelectState.h.

Referenced by selectSomeNeighbor().

◆ hit

CachePeer* PeerSelector::hit
private

Definition at line 159 of file PeerSelectState.h.

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

◆ hit_type

peer_t PeerSelector::hit_type
private

Definition at line 160 of file PeerSelectState.h.

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

◆ id

const InstanceId<PeerSelector> PeerSelector::id
private

Definition at line 166 of file PeerSelectState.h.

◆ initiator_

Initiator PeerSelector::initiator_
private

Definition at line 164 of file PeerSelectState.h.

Referenced by interestedInitiator().

◆ lastError

ErrorState* PeerSelector::lastError
private

Definition at line 140 of file PeerSelectState.h.

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

◆ never_direct

Acl::Answer PeerSelector::never_direct
private

Definition at line 137 of file PeerSelectState.h.

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

◆ peerCountMcastPeerXXX

void* PeerSelector::peerCountMcastPeerXXX = nullptr

Definition at line 101 of file PeerSelectState.h.

Referenced by peerCountMcastPeersAbort().

◆ ping

◆ request

◆ servers

FwdServer* PeerSelector::servers
private

Definition at line 142 of file PeerSelectState.h.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors