34 paths_[pos].available =
true;
38 const auto pathsToTheLeft = pos;
56ResolvedPeers::Paths::iterator
67 return std::make_pair((foundOther ?
paths_.end() : path), foundOther);
74 const auto path =
start();
75 const auto foundNextOrSpare = path !=
paths_.end() &&
76 (currentPeer.
getPeer() != path->connection->getPeer() ||
86 const auto primePeer = currentPeer.
getPeer();
87 const auto path = std::find_if(
start(),
paths_.end(),
89 if (!candidate.available)
91 if (primePeer != candidate.connection->getPeer())
93 if (primeFamily != ConnectionFamily(*candidate.connection))
97 const auto foundNext = path !=
paths_.end() &&
98 primePeer != path->connection->getPeer();
106 const auto path =
start();
107 const auto foundNext = path !=
paths_.end() &&
108 currentPeer.
getPeer() != path->connection->getPeer();
122 const auto found =
findPrime(currentPeer).first;
123 if (found !=
paths_.end())
124 return extractFound(
"same-peer same-family match: ", found);
126 debugs(17, 7,
"no same-peer same-family paths");
133 const auto found =
findSpare(currentPeer).first;
134 if (found !=
paths_.end())
135 return extractFound(
"same-peer different-family match: ", found);
137 debugs(17, 7,
"no same-peer different-family paths");
146 debugs(17, 7, description << path.connection);
148 path.available =
false;
156 const auto cleanPath = path.connection->cloneProfile();
171 if (findings.first !=
paths_.end())
224 return os <<
"[no paths]";
std::ostream & operator<<(std::ostream &os, const ResolvedPeers &peers)
summarized ResolvedPeers (for debugging)
CachePeer * getPeer() const
Comm::ConnectionPointer connection_
half-baked, open, failed, or closed Comm::Connection (or nil)
void print(std::ostream &) const
debugging dump
static constexpr auto npos
non-existent position for nil connection
size_type position_
ResolvedPeers-maintained membership index (or npos)
Finding makeFinding(const Paths::iterator &found, bool foundOther)
finalizes the iterator part of the given preliminary find*() result
Paths paths_
resolved addresses in (peer, family) order
PeerConnectionPointer extractFront()
extracts and returns the first queued address
bool doneWith(const Finding &findings) const
bool haveSpare(const Comm::Connection ¤tPeer)
whether extractSpare() would return a non-nil path right now
Finding findPrime(const Comm::Connection ¤tPeer)
void increaseAvailability()
increments the number of available paths
Finding findSpare(const Comm::Connection ¤tPeer)
size_type availablePaths
the total number of currently available elements in paths_
static int ConnectionFamily(const Comm::Connection &conn)
The protocol family of the given path, AF_INET or AF_INET6.
bool doneWithPrimes(const Comm::Connection ¤tPeer)
whether extractPrime() returns and will continue to return nil
std::pair< Paths::iterator, bool > Finding
bool doneWithPeer(const Comm::Connection ¤tPeer)
whether doneWithPrimes() and doneWithSpares() are true for currentPeer
void reinstatePath(const PeerConnectionPointer &)
size_type size() const
the current number of candidate paths
PeerConnectionPointer extractFound(const char *description, const Paths::iterator &found)
convenience method to finish a successful extract*() call
Paths::size_type size_type
PeerConnectionPointer extractSpare(const Comm::Connection ¤tPeer)
void decreaseAvailability()
decrements the number of available paths
bool empty() const
whether we lack any known candidate paths
bool destinationsFinalized
whether all of the available candidate paths received from DNS
void addPath(const Comm::ConnectionPointer &)
add a candidate path to try after all the existing paths
Finding findPeer(const Comm::Connection ¤tPeer)
PeerConnectionPointer extractPrime(const Comm::Connection ¤tPeer)
bool doneWithSpares(const Comm::Connection ¤tPeer)
whether extractSpare() returns and will continue to return nil
#define debugs(SECTION, LEVEL, CONTENT)