#include <ResolvedPeers.h>

Inheritance diagram for ResolvedPeers:
Collaboration diagram for ResolvedPeers:

Public Types

typedef std::vector< ResolvedPeerPathPaths
 
using size_type = Paths::size_type
 
typedef RefCount< ResolvedPeersPointer
 

Public Member Functions

 ResolvedPeers ()
 
bool empty () const
 whether we lack any known candidate paths More...
 
void addPath (const Comm::ConnectionPointer &)
 add a candidate path to try after all the existing paths More...
 
void reinstatePath (const PeerConnectionPointer &)
 
PeerConnectionPointer extractFront ()
 extracts and returns the first queued address More...
 
PeerConnectionPointer extractPrime (const Comm::Connection &currentPeer)
 
PeerConnectionPointer extractSpare (const Comm::Connection &currentPeer)
 
bool haveSpare (const Comm::Connection &currentPeer)
 whether extractSpare() would return a non-nil path right now More...
 
bool doneWithPrimes (const Comm::Connection &currentPeer)
 whether extractPrime() returns and will continue to return nil More...
 
bool doneWithSpares (const Comm::Connection &currentPeer)
 whether extractSpare() returns and will continue to return nil More...
 
bool doneWithPeer (const Comm::Connection &currentPeer)
 whether doneWithPrimes() and doneWithSpares() are true for currentPeer More...
 
size_type size () const
 the current number of candidate paths More...
 

Public Attributes

bool destinationsFinalized = false
 whether all of the available candidate paths received from DNS More...
 
bool notificationPending = false
 whether HappyConnOpener::noteCandidatesChange() is scheduled to fire More...
 

Private Types

typedef std::pair< Paths::iterator, bool > Finding
 

Private Member Functions

 MEMPROXY_CLASS (ResolvedPeers)
 
Paths::iterator start ()
 
Finding findSpare (const Comm::Connection &currentPeer)
 
Finding findPrime (const Comm::Connection &currentPeer)
 
Finding findPeer (const Comm::Connection &currentPeer)
 
PeerConnectionPointer extractFound (const char *description, const Paths::iterator &found)
 convenience method to finish a successful extract*() call More...
 
Finding makeFinding (const Paths::iterator &found, bool foundOther)
 finalizes the iterator part of the given preliminary find*() result More...
 
bool doneWith (const Finding &findings) const
 
void increaseAvailability ()
 increments the number of available paths More...
 
void decreaseAvailability ()
 decrements the number of available paths More...
 

Static Private Member Functions

static int ConnectionFamily (const Comm::Connection &conn)
 The protocol family of the given path, AF_INET or AF_INET6. More...
 

Private Attributes

Paths paths_
 resolved addresses in (peer, family) order More...
 
size_type pathsToSkip = 0
 
size_type availablePaths = 0
 the total number of currently available elements in paths_ More...
 

Detailed Description

cache_peer and origin server addresses (a.k.a. paths) selected and resolved by the peering code

Definition at line 32 of file ResolvedPeers.h.

Member Typedef Documentation

◆ Finding

typedef std::pair<Paths::iterator, bool> ResolvedPeers::Finding
private

A find*() result: An iterator of the found path (or paths_.end()) and whether the "other" path was found instead.

Definition at line 89 of file ResolvedPeers.h.

◆ Paths

Definition at line 38 of file ResolvedPeers.h.

◆ Pointer

Definition at line 40 of file ResolvedPeers.h.

◆ size_type

using ResolvedPeers::size_type = Paths::size_type

Definition at line 39 of file ResolvedPeers.h.

Constructor & Destructor Documentation

◆ ResolvedPeers()

ResolvedPeers::ResolvedPeers ( )

Definition at line 16 of file ResolvedPeers.cc.

References Config, SquidConfig::forward_max_tries, and paths_.

Member Function Documentation

◆ addPath()

void ResolvedPeers::addPath ( const Comm::ConnectionPointer path)

Definition at line 46 of file ResolvedPeers.cc.

References increaseAvailability(), Must, and paths_.

Referenced by FwdState::noteDestination(), and TunnelStateData::noteDestination().

◆ ConnectionFamily()

int ResolvedPeers::ConnectionFamily ( const Comm::Connection conn)
staticprivate

Definition at line 197 of file ResolvedPeers.cc.

References conn.

Referenced by findPrime(), and findSpare().

◆ decreaseAvailability()

void ResolvedPeers::decreaseAvailability ( )
private

Definition at line 212 of file ResolvedPeers.cc.

References assert, and availablePaths.

Referenced by extractFound().

◆ doneWith()

bool ResolvedPeers::doneWith ( const Finding findings) const
private

whether paths_ have no (and will have no) Xs for the current peer based on the given findX(current peer) result

Definition at line 167 of file ResolvedPeers.cc.

References destinationsFinalized, paths_, and true.

Referenced by doneWithPeer(), doneWithPrimes(), and doneWithSpares().

◆ doneWithPeer()

bool ResolvedPeers::doneWithPeer ( const Comm::Connection currentPeer)

Definition at line 191 of file ResolvedPeers.cc.

References doneWith(), and findPeer().

Referenced by HappyConnOpener::checkForNewConnection().

◆ doneWithPrimes()

bool ResolvedPeers::doneWithPrimes ( const Comm::Connection currentPeer)

Definition at line 185 of file ResolvedPeers.cc.

References doneWith(), and findPrime().

Referenced by HappyConnOpener::updateSpareWaitAfterPrimeFailure().

◆ doneWithSpares()

bool ResolvedPeers::doneWithSpares ( const Comm::Connection currentPeer)

◆ empty()

◆ extractFound()

PeerConnectionPointer ResolvedPeers::extractFound ( const char *  description,
const Paths::iterator &  found 
)
private

Definition at line 141 of file ResolvedPeers.cc.

References assert, debugs, decreaseAvailability(), paths_, and pathsToSkip.

Referenced by extractFront(), extractPrime(), and extractSpare().

◆ extractFront()

PeerConnectionPointer ResolvedPeers::extractFront ( )

Definition at line 111 of file ResolvedPeers.cc.

References empty(), extractFound(), Must, and start().

Referenced by HappyConnOpener::checkForNewConnection().

◆ extractPrime()

PeerConnectionPointer ResolvedPeers::extractPrime ( const Comm::Connection currentPeer)

extracts and returns the first same-peer same-family address

Returns
nil if it cannot find the requested address

Definition at line 118 of file ResolvedPeers.cc.

References debugs, extractFound(), findPrime(), and paths_.

Referenced by HappyConnOpener::maybeOpenAnotherPrimeConnection().

◆ extractSpare()

PeerConnectionPointer ResolvedPeers::extractSpare ( const Comm::Connection currentPeer)

extracts and returns the first same-peer different-family address

Returns
nil if it cannot find the requested address

Definition at line 129 of file ResolvedPeers.cc.

References debugs, extractFound(), findSpare(), and paths_.

Referenced by HappyConnOpener::maybeOpenSpareConnection(), and HappyConnOpener::noteSpareAllowance().

◆ findPeer()

ResolvedPeers::Finding ResolvedPeers::findPeer ( const Comm::Connection currentPeer)
private
Returns
the first available same-peer Finding or <end,...>

Definition at line 102 of file ResolvedPeers.cc.

References Comm::Connection::getPeer(), makeFinding(), paths_, and start().

Referenced by doneWithPeer().

◆ findPrime()

ResolvedPeers::Finding ResolvedPeers::findPrime ( const Comm::Connection currentPeer)
private
Returns
the first available same-peer same-family Finding or <end,...>

Definition at line 70 of file ResolvedPeers.cc.

References ConnectionFamily(), Comm::Connection::getPeer(), makeFinding(), paths_, and start().

Referenced by doneWithPrimes(), and extractPrime().

◆ findSpare()

ResolvedPeers::Finding ResolvedPeers::findSpare ( const Comm::Connection currentPeer)
private
Returns
the first available same-peer different-family Finding or <end,...>

Definition at line 81 of file ResolvedPeers.cc.

References ConnectionFamily(), Comm::Connection::getPeer(), makeFinding(), paths_, and start().

Referenced by doneWithSpares(), extractSpare(), and haveSpare().

◆ haveSpare()

bool ResolvedPeers::haveSpare ( const Comm::Connection currentPeer)

Definition at line 159 of file ResolvedPeers.cc.

References findSpare(), and paths_.

Referenced by HappyConnOpener::maybeOpenSpareConnection().

◆ increaseAvailability()

void ResolvedPeers::increaseAvailability ( )
private

Definition at line 204 of file ResolvedPeers.cc.

References assert, availablePaths, and paths_.

Referenced by addPath(), and reinstatePath().

◆ makeFinding()

ResolvedPeers::Finding ResolvedPeers::makeFinding ( const Paths::iterator &  found,
bool  foundOther 
)
private

Definition at line 63 of file ResolvedPeers.cc.

References paths_.

Referenced by findPeer(), findPrime(), and findSpare().

◆ MEMPROXY_CLASS()

ResolvedPeers::MEMPROXY_CLASS ( ResolvedPeers  )
private

◆ reinstatePath()

void ResolvedPeers::reinstatePath ( const PeerConnectionPointer path)

makes the previously extracted path available for extraction at its original position

Definition at line 23 of file ResolvedPeers.cc.

References assert, debugs, increaseAvailability(), Must, paths_, pathsToSkip, and PeerConnectionPointer::position_.

Referenced by HappyConnOpener::cancelAttempt(), and FwdState::fail().

◆ size()

size_type ResolvedPeers::size ( ) const
inline

Definition at line 78 of file ResolvedPeers.h.

References availablePaths.

Referenced by operator<<().

◆ start()

ResolvedPeers::Paths::iterator ResolvedPeers::start ( )
private
Returns
the beginning iterator for any available-path search

Definition at line 55 of file ResolvedPeers.cc.

References Must, paths_, and pathsToSkip.

Referenced by extractFront(), findPeer(), findPrime(), and findSpare().

Member Data Documentation

◆ availablePaths

size_type ResolvedPeers::availablePaths = 0
private

Definition at line 114 of file ResolvedPeers.h.

Referenced by decreaseAvailability(), empty(), increaseAvailability(), and size().

◆ destinationsFinalized

◆ notificationPending

◆ paths_

◆ pathsToSkip

size_type ResolvedPeers::pathsToSkip = 0
private

the number of leading paths_ elements that are all currently unavailable i.e. the size of the front paths_ segment comprised of unavailable items i.e. the position of the first available path (or paths_.size())

Definition at line 111 of file ResolvedPeers.h.

Referenced by extractFound(), reinstatePath(), and start().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors