]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ResolvedPeers.h
2 * Copyright (C) 1996-2020 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_RESOLVEDPEERS_H
10 #define SQUID_RESOLVEDPEERS_H
12 #include "base/RefCount.h"
13 #include "comm/forward.h"
17 /// cache_peer and origin server addresses (a.k.a. paths)
18 /// selected and resolved by the peering code
19 class ResolvedPeers
: public RefCountable
21 MEMPROXY_CLASS(ResolvedPeers
);
24 typedef RefCount
<ResolvedPeers
> Pointer
;
28 /// whether we lack any known candidate paths
29 bool empty() const { return paths_
.empty(); }
31 /// add a candidate path to try after all the existing paths
32 void addPath(const Comm::ConnectionPointer
&);
34 /// add a candidate path to try before all the existing paths
35 void retryPath(const Comm::ConnectionPointer
&);
37 /// extracts and returns the first queued address
38 Comm::ConnectionPointer
extractFront();
40 /// extracts and returns the first same-peer same-family address
41 /// \returns nil if it cannot find the requested address
42 Comm::ConnectionPointer
extractPrime(const Comm::Connection
¤tPeer
);
44 /// extracts and returns the first same-peer different-family address
45 /// \returns nil if it cannot find the requested address
46 Comm::ConnectionPointer
extractSpare(const Comm::Connection
¤tPeer
);
48 /// whether extractSpare() would return a non-nil path right now
49 bool haveSpare(const Comm::Connection
¤tPeer
);
51 /// whether extractPrime() returns and will continue to return nil
52 bool doneWithPrimes(const Comm::Connection
¤tPeer
) const;
54 /// whether extractSpare() returns and will continue to return nil
55 bool doneWithSpares(const Comm::Connection
¤tPeer
);
57 /// whether doneWithPrimes() and doneWithSpares() are true for currentPeer
58 bool doneWithPeer(const Comm::Connection
¤tPeer
) const;
60 /// the current number of candidate paths
61 Comm::ConnectionList::size_type
size() const { return paths_
.size(); }
63 /// whether all of the available candidate paths received from DNS
64 bool destinationsFinalized
= false;
66 /// whether HappyConnOpener::noteCandidatesChange() is scheduled to fire
67 bool notificationPending
= false;
70 /// The protocol family of the given path, AF_INET or AF_INET6
71 static int ConnectionFamily(const Comm::Connection
&conn
);
73 Comm::ConnectionList::iterator
findSpareOrNextPeer(const Comm::Connection
¤tPeer
);
74 Comm::ConnectionPointer
extractFound(const char *description
, const Comm::ConnectionList::iterator
&found
);
76 Comm::ConnectionList paths_
;
79 /// summarized ResolvedPeers (for debugging)
80 std::ostream
&operator <<(std::ostream
&, const ResolvedPeers
&);
82 #endif /* SQUID_RESOLVEDPEERS_H */