CachePeer.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#ifndef SQUID_CACHEPEER_H_
10#define SQUID_CACHEPEER_H_
11
12#include "acl/forward.h"
13#include "base/CbcPointer.h"
14#include "enums.h"
15#include "http/StatusCode.h"
16#include "icp_opcode.h"
17#include "ip/Address.h"
19
20#include <iosfwd>
21
22//TODO: remove, it is unconditionally defined and always used.
23#define PEER_MULTICAST_SIBLINGS 1
24
26class PconnPool;
27class PeerDigest;
28class PeerPoolMgr;
29
31{
33
34public:
35 explicit CachePeer(const char *hostname);
36 ~CachePeer();
37
39 void noteSuccess();
40
44
46 void rename(const char *);
47
49 time_t connectTimeout() const;
50
52 u_int index = 0;
53
60 char *name = nullptr;
61
65 char *host = nullptr;
66
68
70
71 struct {
72 int pings_sent = 0;
73 int pings_acked = 0;
74 int fetches = 0;
75 int rtt = 0;
79 time_t probe_start = 0;
80 time_t last_query = 0;
81 time_t last_reply = 0;
85 int conn_open = 0;
87
88 struct icp_ {
89 icp_() { memset(&counts, 0, sizeof(counts)); }
92 unsigned short port = CACHE_ICP_PORT;
93 } icp;
94
95#if USE_HTCP
96 struct {
97 double version = 0.0;
98 int counts[2] = {0, 0};
99 unsigned short port = 0;
101#endif
102
103 unsigned short http_port = CACHE_HTTP_PORT;
105 acl_access *access = nullptr;
106
107 struct {
108 bool proxy_only = false;
109 bool no_query = false;
110 bool background_ping = false;
111 bool no_digest = false;
112 bool default_parent = false;
113 bool roundrobin = false;
115 bool mcast_responder = false;
116 bool closest_only = false;
117#if USE_HTCP
118 bool htcp = false;
119 bool htcp_oldsquid = false;
120 bool htcp_no_clr = false;
121 bool htcp_no_purge_clr = false;
122 bool htcp_only_clr = false;
123 bool htcp_forward_clr = false;
124#endif
125 bool no_netdb_exchange = false;
126#if USE_DELAY_POOLS
127 bool no_delay = false;
128#endif
129 bool allow_miss = false;
130 bool carp = false;
131 struct {
132 bool set = false; //If false, whole url is to be used. Overrides others
133 bool scheme = false;
134 bool host = false;
135 bool port = false;
136 bool path = false;
137 bool params = false;
139#if USE_AUTH
140 bool userhash = false;
141#endif
142 bool sourcehash = false;
143 bool originserver = false;
144 bool no_tproxy = false;
145#if PEER_MULTICAST_SIBLINGS
146 bool mcast_siblings = false;
147#endif
148 bool auth_no_keytab = false;
150
151 int weight = 1;
152 int basetime = 0;
153
154 struct {
155 double avg_n_members = 0.0;
158 int ttl = 0;
159 int id = 0;
160
161 struct {
163 bool counting = false;
166
167#if USE_CACHE_DIGESTS
168 PeerDigest *digest = nullptr;
169 char *digest_url = nullptr;
170#endif
171
175 int tcp_up = 0;
176
178 bool reprobe = false;
179
181 int n_addresses = 0;
182 int rr_count = 0;
183 int testing_now = 0;
184
185 struct {
186 unsigned int hash = 0;
187 double load_multiplier = 0.0;
188 double load_factor = 0.0;
190#if USE_AUTH
191 struct {
192 unsigned int hash = 0;
193 double load_multiplier = 0.0;
194 double load_factor = 0.0;
196#endif
197 struct {
198 unsigned int hash = 0;
199 double load_multiplier = 0.0;
200 double load_factor = 0.0;
202
203 char *login = nullptr; /* Proxy authorization */
206 int max_conn = 0;
207
209 struct {
210 PconnPool *pool = nullptr;
212 int limit = 0;
213 bool waitingForClose = false;
215
216 char *domain = nullptr;
217
222
225
226private:
227 void countFailure();
228};
229
232inline void
234{
235 if (peer)
236 peer->noteSuccess();
237}
238
242inline void
244{
245 if (peer)
246 peer->noteFailure(code);
247}
248
250std::ostream &operator <<(std::ostream &, const CachePeer &);
251
252#endif /* SQUID_CACHEPEER_H_ */
253
void NoteOutgoingConnectionSuccess(CachePeer *const peer)
Definition: CachePeer.h:233
void NoteOutgoingConnectionFailure(CachePeer *const peer, const Http::StatusCode code)
Definition: CachePeer.h:243
std::ostream & operator<<(std::ostream &, const CachePeer &)
identify the given cache peer in cache.log messages and such
Definition: CachePeer.cc:127
#define acl_access
Definition: forward.h:45
CbcPointer< PeerPoolMgr > mgr
pool manager
Definition: CachePeer.h:211
acl_access * access
Definition: CachePeer.h:105
bool closest_only
Definition: CachePeer.h:116
int n_keepalives_recv
Definition: CachePeer.h:78
int weight
Definition: CachePeer.h:151
CachePeer(const char *hostname)
Definition: CachePeer.cc:23
int n_keepalives_sent
Definition: CachePeer.h:77
bool no_tproxy
Definition: CachePeer.h:144
void noteSuccess()
reacts to a successful establishment of a connection to this cache_peer
Definition: CachePeer.cc:61
bool htcp_oldsquid
Definition: CachePeer.h:119
struct CachePeer::@28 options
bool no_query
Definition: CachePeer.h:109
struct CachePeer::@28::@34 carp_key
NeighborTypeDomainList * typelist
Definition: CachePeer.h:104
int basetime
Definition: CachePeer.h:152
bool originserver
Definition: CachePeer.h:143
time_t probe_start
Definition: CachePeer.h:79
bool background_ping
Definition: CachePeer.h:110
peer_t type
Definition: CachePeer.h:67
bool scheme
Definition: CachePeer.h:133
bool roundrobin
Definition: CachePeer.h:113
int n_addresses
Definition: CachePeer.h:181
int connection_auth
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:224
unsigned short http_port
Definition: CachePeer.h:103
bool proxy_only
Definition: CachePeer.h:108
int pings_sent
Definition: CachePeer.h:72
int logged_state
so we can print dead/revived msgs
Definition: CachePeer.h:84
char * login
Definition: CachePeer.h:203
time_t last_connect_probe
Definition: CachePeer.h:83
bool htcp_no_purge_clr
Definition: CachePeer.h:121
char * host
Definition: CachePeer.h:65
Security::PeerOptions secure
security settings for peer connection
Definition: CachePeer.h:219
time_t connect_timeout_raw
connect_timeout; use connectTimeout() instead!
Definition: CachePeer.h:204
bool mcast_siblings
Definition: CachePeer.h:146
char * domain
Forced domain.
Definition: CachePeer.h:216
int limit
the limit itself
Definition: CachePeer.h:212
time_t last_connect_failure
Definition: CachePeer.h:82
unsigned short port
Definition: CachePeer.h:99
time_t last_query
Definition: CachePeer.h:80
CBDATA_CLASS(CachePeer)
double load_factor
normalized weight value
Definition: CachePeer.h:188
PeerDigest * digest
Definition: CachePeer.h:168
int n_replies_expected
Definition: CachePeer.h:157
struct CachePeer::@29 mcast
int tcp_up
Definition: CachePeer.h:175
bool counting
Definition: CachePeer.h:163
int rtt
Definition: CachePeer.h:75
bool auth_no_keytab
Definition: CachePeer.h:148
bool no_digest
Definition: CachePeer.h:111
bool htcp_forward_clr
Definition: CachePeer.h:123
void countFailure()
noteFailure() helper for handling failures attributed to this peer
Definition: CachePeer.cc:85
Ip::Address in_addr
Definition: CachePeer.h:69
PconnPool * pool
idle connection pool for this peer
Definition: CachePeer.h:210
int rr_count
Definition: CachePeer.h:182
bool waitingForClose
a conn must close before we open a standby conn
Definition: CachePeer.h:213
bool sourcehash
Definition: CachePeer.h:142
Security::SessionStatePointer sslSession
Definition: CachePeer.h:221
~CachePeer()
Definition: CachePeer.cc:30
u_int index
n-th cache_peer directive, starting with 1
Definition: CachePeer.h:52
int connect_fail_limit
Definition: CachePeer.h:205
double avg_n_members
Definition: CachePeer.h:155
int front_end_https
0 - off, 1 - on, 2 - auto
Definition: CachePeer.h:223
int n_times_counted
Definition: CachePeer.h:156
struct CachePeer::icp_ icp
struct CachePeer::@26 stats
time_t last_reply
Definition: CachePeer.h:81
int pings_acked
Definition: CachePeer.h:73
bool no_netdb_exchange
Definition: CachePeer.h:125
int max_conn
Definition: CachePeer.h:206
Security::ContextPointer sslContext
Definition: CachePeer.h:220
struct CachePeer::@33 standby
optional "cache_peer standby=limit" feature
bool htcp_only_clr
Definition: CachePeer.h:122
bool params
Definition: CachePeer.h:137
time_t connectTimeout() const
Definition: CachePeer.cc:119
struct CachePeer::@29::@35 flags
int counts[2]
Definition: CachePeer.h:98
bool count_event_pending
Definition: CachePeer.h:162
void rename(const char *)
(re)configure cache_peer name=value
Definition: CachePeer.cc:109
char * name
Definition: CachePeer.h:60
Ip::Address addresses[10]
Definition: CachePeer.h:180
bool userhash
Definition: CachePeer.h:140
int conn_open
current opened connections
Definition: CachePeer.h:85
int testing_now
Definition: CachePeer.h:183
bool default_parent
Definition: CachePeer.h:112
bool carp
Definition: CachePeer.h:130
bool reprobe
whether to do another TCP probe after current TCP probes
Definition: CachePeer.h:178
unsigned int hash
Definition: CachePeer.h:186
bool allow_miss
Definition: CachePeer.h:129
struct CachePeer::@27 htcp
char * digest_url
Definition: CachePeer.h:169
int ignored_replies
Definition: CachePeer.h:76
int fetches
Definition: CachePeer.h:74
double version
Definition: CachePeer.h:97
double load_multiplier
Definition: CachePeer.h:187
void noteFailure(Http::StatusCode code)
Definition: CachePeer.cc:73
bool mcast_responder
Definition: CachePeer.h:115
bool weighted_roundrobin
Definition: CachePeer.h:114
bool path
Definition: CachePeer.h:136
bool htcp_no_clr
Definition: CachePeer.h:120
bool no_delay
Definition: CachePeer.h:127
bool set
Definition: CachePeer.h:132
representation of a neighbor_type_domain configuration directive. A POD
Maintains an fixed-size "standby" PconnPool for a single CachePeer.
Definition: PeerPoolMgr.h:23
TLS squid.conf settings for a remote server peer.
Definition: PeerOptions.h:26
#define ICP_VERSION_CURRENT
Definition: defines.h:46
#define PEER_ALIVE
Definition: defines.h:86
peer_t
Definition: enums.h:27
@ PEER_NONE
Definition: enums.h:28
@ ICP_END
Definition: icp_opcode.h:39
StatusCode
Definition: StatusCode.h:20
std::shared_ptr< SSL_CTX > ContextPointer
Definition: Context.h:29
std::unique_ptr< SSL_SESSION, HardFun< void, SSL_SESSION *, &SSL_SESSION_free > > SessionStatePointer
Definition: Session.h:51
int code
Definition: smb-errors.c:145
#define CACHE_ICP_PORT
Definition: squid.h:17
#define CACHE_HTTP_PORT
Definition: squid.h:16
unsigned short port
Definition: CachePeer.h:92
int counts[ICP_END+1]
Definition: CachePeer.h:91

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors