#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 (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)
 

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

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

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

◆ 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 370 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 342 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().

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

References handlePingTimeout().

◆ interestedInitiator()

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

Definition at line 1135 of file peer_select.cc.

References debugs, and initiator_.

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().

Implements Dns::IpReceiver.

Definition at line 538 of file peer_select.cc.

References FwdServer::_peer, al, 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, and HttpRequest::url.

◆ 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 501 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 400 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 1154 of file peer_select.cc.

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

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(), resolveSelected(), and wantsMoreDestinations().

◆ 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 noteIps(), resolveSelected(), and ~PeerSelector().

◆ 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 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