#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...
 
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 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
 
static EVH HandlePingTimeout
 

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 155 of file PeerSelectState.h.

Constructor & Destructor Documentation

◆ PeerSelector()

PeerSelector::PeerSelector ( PeerSelectionInitiator initiator)
explicit

Definition at line 957 of file peer_select.cc.

◆ ~PeerSelector()

PeerSelector::~PeerSelector ( )
overridevirtual

Member Function Documentation

◆ addSelection()

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

Definition at line 935 of file peer_select.cc.

References debugs, duplicate, FwdServer::FwdServer(), PINNED, and server.

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

References ACCESS_ALLOWED, ACCESS_AUTH_REQUIRED, ACCESS_DENIED, ACCESS_DUNNO, CheckAlwaysDirectDone, data, DBG_IMPORTANT, debugs, DIRECT_YES, and DirectStr.

◆ checkNetdbDirect()

int PeerSelector::checkNetdbDirect ( )
protected

◆ checkNeverDirectDone()

void PeerSelector::checkNeverDirectDone ( const Acl::Answer  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, CheckNeverDirectDone, data, DBG_IMPORTANT, debugs, DIRECT_NO, and DirectStr.

◆ handleHtcpParentMiss()

◆ handleHtcpReply()

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

Definition at line 855 of file peer_select.cc.

References debugs, HtcpReplyData::hit, p, PEER_PARENT, and type.

◆ handleIcpParentMiss()

◆ handleIcpReply()

void PeerSelector::handleIcpReply ( CachePeer p,
const peer_t  type,
icp_common_t header 
)
protected

◆ handlePath()

◆ handlePingTimeout()

void PeerSelector::handlePingTimeout ( )
protected

Definition at line 753 of file peer_select.cc.

References data, debugs, HandlePingTimeout, PeerStats, and PING_DONE.

◆ interestedInitiator()

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

Definition at line 990 of file peer_select.cc.

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

Referenced by handlePath().

◆ noteIp()

void PeerSelector::noteIp ( const Ip::Address )
overridevirtual

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

References FwdServer::_peer, FwdServer::code, debugs, ERR_DNS_FAIL, Dns::LookupDetails::error, HIER_DIRECT, CachePeer::host, FwdServer::next, NULL, request(), Http::scServiceUnavailable, _request::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 360 of file peer_select.cc.

References request().

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

References debugs.

◆ selectMore()

void PeerSelector::selectMore ( )

If we don't know whether DIRECT is permitted ...

check always_direct;

check never_direct;

if we are accelerating, direct is not an option.

if we are in a forwarding-loop, direct is not an option.

Definition at line 466 of file peer_select.cc.

References ACCESS_DUNNO, SquidConfig::accessList, ACLFilledChecklist::al, SquidConfig::AlwaysDirect, Config, debugs, DIRECT_MAYBE, DIRECT_NO, DIRECT_UNKNOWN, DIRECT_YES, DirectStr, _request::method, SquidConfig::NeverDirect, SquidConfig::nonhierarchical_direct, NULL, SquidConfig::onoff, peerAllowedToUse(), PING_DONE, PING_NONE, PING_WAITING, SquidConfig::prefer_direct, request(), ACLFilledChecklist::syncAle(), and _request::url.

◆ selectPinned()

void PeerSelector::selectPinned ( )
protected

Definition at line 561 of file peer_select.cc.

References DIRECT_NO, peerAllowedToUse(), PING_DONE, PINNED, and request().

◆ selectSomeDirect()

void PeerSelector::selectSomeDirect ( )
protected

Definition at line 676 of file peer_select.cc.

References DIRECT_NO, HIER_DIRECT, AnyP::PROTO_WAIS, request(), and _request::url.

◆ selectSomeNeighbor()

void PeerSelector::selectSomeNeighbor ( )
protected

Selects a neighbor (parent or sibling) based on one of the following methods: Cache Digests CARP ICMP Netdb RTT estimates ICP/HTCP queries

Definition at line 587 of file peer_select.cc.

References assert, CD_PARENT_HIT, CD_SIBLING_HIT, CLOSEST_PARENT, FwdServer::code, current_time, DBG_CRITICAL, debugs, DIRECT_YES, eventAdd(), HIER_NONE, neighborsDigestSelect(), neighborsUdpPing(), neighborType(), netdbClosestParent(), p, PEER_PARENT, peerSelectIcpPing(), PING_DONE, PING_NONE, PING_WAITING, request(), and _request::url.

◆ selectSomeNeighborReplies()

void PeerSelector::selectSomeNeighborReplies ( )
protected

◆ selectSomeParent()

◆ toCbdata()

virtual void* CbdataParent::toCbdata ( )
pure virtualinherited

◆ url()

const SBuf PeerSelector::url ( ) const

Definition at line 976 of file peer_select.cc.

References HttpRequest::effectiveRequestUri(), entry, request, and StoreEntry::url().

Referenced by handlePath().

◆ wantsMoreDestinations()

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

Definition at line 1009 of file peer_select.cc.

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

Member Data Documentation

◆ acl_checklist

ACLChecklist* PeerSelector::acl_checklist
private

Definition at line 153 of file PeerSelectState.h.

◆ al

AccessLogEntry::Pointer PeerSelector::al

Definition at line 89 of file PeerSelectState.h.

Referenced by peerAllowedToUse().

◆ always_direct

Acl::Answer PeerSelector::always_direct
private

Definition at line 128 of file PeerSelectState.h.

Referenced by handlePath().

◆ CheckAlwaysDirectDone

void PeerSelector::CheckAlwaysDirectDone
staticprotected

Definition at line 123 of file PeerSelectState.h.

Referenced by checkAlwaysDirectDone().

◆ CheckNeverDirectDone

void PeerSelector::CheckNeverDirectDone
staticprotected

Definition at line 124 of file PeerSelectState.h.

Referenced by checkNeverDirectDone().

◆ closest_parent_miss

Ip::Address PeerSelector::closest_parent_miss
private

Definition at line 146 of file PeerSelectState.h.

◆ direct

int PeerSelector::direct
private

Definition at line 130 of file PeerSelectState.h.

◆ entry

StoreEntry* PeerSelector::entry

Definition at line 90 of file PeerSelectState.h.

Referenced by url().

◆ first_parent_miss

Ip::Address PeerSelector::first_parent_miss
private

Definition at line 144 of file PeerSelectState.h.

◆ foundPaths

size_t PeerSelector::foundPaths = 0
private

Definition at line 131 of file PeerSelectState.h.

Referenced by handlePath(), and wantsMoreDestinations().

◆ HandlePingReply

void PeerSelector::HandlePingReply
staticprotected

Definition at line 122 of file PeerSelectState.h.

Referenced by handleHtcpParentMiss().

◆ HandlePingTimeout

void PeerSelector::HandlePingTimeout
staticprotected

Definition at line 125 of file PeerSelectState.h.

Referenced by handlePingTimeout().

◆ hit

CachePeer* PeerSelector::hit
private

Definition at line 151 of file PeerSelectState.h.

◆ hit_type

peer_t PeerSelector::hit_type
private

Definition at line 152 of file PeerSelectState.h.

◆ id

const InstanceId<PeerSelector> PeerSelector::id
private

Definition at line 158 of file PeerSelectState.h.

◆ initiator_

Initiator PeerSelector::initiator_
private

Definition at line 156 of file PeerSelectState.h.

Referenced by interestedInitiator().

◆ lastError

ErrorState* PeerSelector::lastError
private

Definition at line 132 of file PeerSelectState.h.

◆ never_direct

Acl::Answer PeerSelector::never_direct
private

Definition at line 129 of file PeerSelectState.h.

Referenced by handlePath().

◆ peerCountMcastPeerXXX

void* PeerSelector::peerCountMcastPeerXXX = nullptr

Definition at line 92 of file PeerSelectState.h.

◆ ping

ping_data PeerSelector::ping

Definition at line 94 of file PeerSelectState.h.

Referenced by handlePath().

◆ request

◆ servers

FwdServer* PeerSelector::servers
private

Definition at line 134 of file PeerSelectState.h.


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors