CBDATA_CLASS_INIT(CachePeer);
-CachePeer::CachePeer() :
- index(0),
- name(NULL),
- host(NULL),
- type(PEER_NONE),
- http_port(CACHE_HTTP_PORT),
- typelist(NULL),
- access(NULL),
- weight(1),
- basetime(0),
-#if USE_CACHE_DIGESTS
- digest(NULL),
- digest_url(NULL),
-#endif
- tcp_up(0),
- n_addresses(0),
- rr_count(0),
- next(NULL),
- testing_now(false),
- login(NULL),
- connect_timeout(0),
- connect_fail_limit(0),
- max_conn(0),
- domain(NULL),
- front_end_https(0),
- connection_auth(2 /* auto */)
-{
- memset(&stats, 0, sizeof(stats));
- stats.logged_state = PEER_ALIVE;
-
- memset(&icp, 0, sizeof(icp));
- icp.port = CACHE_ICP_PORT;
- icp.version = ICP_VERSION_CURRENT;
-
-#if USE_HTCP
- memset(&htcp, 0, sizeof(htcp));
-#endif
- memset(&options, 0, sizeof(options));
- memset(&mcast, 0, sizeof(mcast));
- memset(&carp, 0, sizeof(carp));
-#if USE_AUTH
- memset(&userhash, 0, sizeof(userhash));
-#endif
- memset(&sourcehash, 0, sizeof(sourcehash));
-
- standby.pool = NULL;
- standby.limit = 0;
- standby.waitingForClose = false;
-}
-
CachePeer::~CachePeer()
{
xfree(name);
CBDATA_CLASS(CachePeer);
public:
- CachePeer();
+ CachePeer() = default;
~CachePeer();
- u_int index;
- char *name;
- char *host;
- peer_t type;
+ u_int index = 0;
+ char *name = nullptr;
+ char *host = nullptr;
+ peer_t type = PEER_NONE;
Ip::Address in_addr;
struct {
- int pings_sent;
- int pings_acked;
- int fetches;
- int rtt;
- int ignored_replies;
- int n_keepalives_sent;
- int n_keepalives_recv;
- time_t probe_start;
- time_t last_query;
- time_t last_reply;
- time_t last_connect_failure;
- time_t last_connect_probe;
- int logged_state; /* so we can print dead/revived msgs */
- int conn_open; /* current opened connections */
+ int pings_sent = 0;
+ int pings_acked = 0;
+ int fetches = 0;
+ int rtt = 0;
+ int ignored_replies = 0;
+ int n_keepalives_sent = 0;
+ int n_keepalives_recv = 0;
+ time_t probe_start = 0;
+ time_t last_query = 0;
+ time_t last_reply = 0;
+ time_t last_connect_failure = 0;
+ time_t last_connect_probe = 0;
+ int logged_state = PEER_ALIVE; ///< so we can print dead/revived msgs
+ int conn_open = 0; ///< current opened connections
} stats;
- struct {
- int version;
+ struct icp_ {
+ icp_() { memset(&counts, 0, sizeof(counts)); }
+ int version = ICP_VERSION_CURRENT;
int counts[ICP_END+1];
- unsigned short port;
+ unsigned short port = CACHE_ICP_PORT;
} icp;
#if USE_HTCP
struct {
- double version;
- int counts[2];
- unsigned short port;
+ double version = 0.0;
+ int counts[2] = {0, 0};
+ unsigned short port = 0;
} htcp;
#endif
- unsigned short http_port;
- NeighborTypeDomainList *typelist;
- acl_access *access;
+ unsigned short http_port = CACHE_HTTP_PORT;
+ NeighborTypeDomainList *typelist = nullptr;
+ acl_access *access = nullptr;
struct {
- bool proxy_only;
- bool no_query;
- bool background_ping;
- bool no_digest;
- bool default_parent;
- bool roundrobin;
- bool weighted_roundrobin;
- bool mcast_responder;
- bool closest_only;
+ bool proxy_only = false;
+ bool no_query = false;
+ bool background_ping = false;
+ bool no_digest = false;
+ bool default_parent = false;
+ bool roundrobin = false;
+ bool weighted_roundrobin = false;
+ bool mcast_responder = false;
+ bool closest_only = false;
#if USE_HTCP
- bool htcp;
- bool htcp_oldsquid;
- bool htcp_no_clr;
- bool htcp_no_purge_clr;
- bool htcp_only_clr;
- bool htcp_forward_clr;
+ bool htcp = false;
+ bool htcp_oldsquid = false;
+ bool htcp_no_clr = false;
+ bool htcp_no_purge_clr = false;
+ bool htcp_only_clr = false;
+ bool htcp_forward_clr = false;
#endif
- bool no_netdb_exchange;
+ bool no_netdb_exchange = false;
#if USE_DELAY_POOLS
- bool no_delay;
+ bool no_delay = false;
#endif
- bool allow_miss;
- bool carp;
+ bool allow_miss = false;
+ bool carp = false;
struct {
- bool set; //If false, whole url is to be used. Overrides others
- bool scheme;
- bool host;
- bool port;
- bool path;
- bool params;
+ bool set = false; //If false, whole url is to be used. Overrides others
+ bool scheme = false;
+ bool host = false;
+ bool port = false;
+ bool path = false;
+ bool params = false;
} carp_key;
#if USE_AUTH
- bool userhash;
+ bool userhash = false;
#endif
- bool sourcehash;
- bool originserver;
- bool no_tproxy;
+ bool sourcehash = false;
+ bool originserver = false;
+ bool no_tproxy = false;
#if PEER_MULTICAST_SIBLINGS
- bool mcast_siblings;
+ bool mcast_siblings = false;
#endif
- bool auth_no_keytab;
+ bool auth_no_keytab = false;
} options;
- int weight;
- int basetime;
+ int weight = 1;
+ int basetime = 0;
struct {
- double avg_n_members;
- int n_times_counted;
- int n_replies_expected;
- int ttl;
- int id;
+ double avg_n_members = 0.0;
+ int n_times_counted = 0;
+ int n_replies_expected = 0;
+ int ttl = 0;
+ int id = 0;
struct {
- bool count_event_pending;
- bool counting;
+ bool count_event_pending = false;
+ bool counting = false;
} flags;
} mcast;
-#if USE_CACHE_DIGESTS
- PeerDigest *digest;
- char *digest_url;
+#if USE_CACHE_DIGESTS
+ PeerDigest *digest = nullptr;
+ char *digest_url = nullptr;
#endif
- int tcp_up; /* 0 if a connect() fails */
+ int tcp_up = 0; /* 0 if a connect() fails */
Ip::Address addresses[10];
- int n_addresses;
- int rr_count;
- CachePeer *next;
- int testing_now;
+ int n_addresses = 0;
+ int rr_count = 0;
+ CachePeer *next = nullptr;
+ int testing_now = 0;
struct {
- unsigned int hash;
- double load_multiplier;
- double load_factor; /* normalized weight value */
+ unsigned int hash = 0;
+ double load_multiplier = 0.0;
+ double load_factor = 0.0; ///< normalized weight value
} carp;
#if USE_AUTH
struct {
- unsigned int hash;
- double load_multiplier;
- double load_factor; /* normalized weight value */
+ unsigned int hash = 0;
+ double load_multiplier = 0.0;
+ double load_factor = 0.0; ///< normalized weight value
} userhash;
#endif
struct {
- unsigned int hash;
- double load_multiplier;
- double load_factor; /* normalized weight value */
+ unsigned int hash = 0;
+ double load_multiplier = 0.0;
+ double load_factor = 0.0; ///< normalized weight value
} sourcehash;
- char *login; /* Proxy authorization */
- time_t connect_timeout;
- int connect_fail_limit;
- int max_conn;
+ char *login = nullptr; /* Proxy authorization */
+ time_t connect_timeout = 0;
+ int connect_fail_limit = 0;
+ int max_conn = 0;
+
+ /// optional "cache_peer standby=limit" feature
struct {
- PconnPool *pool; ///< idle connection pool for this peer
- CbcPointer<PeerPoolMgr> mgr; ///< pool manager
- int limit; ///< the limit itself
- bool waitingForClose; ///< a conn must close before we open a standby conn
- } standby; ///< optional "cache_peer standby=limit" feature
- char *domain; /* Forced domain */
+ PconnPool *pool = nullptr; ///< idle connection pool for this peer
+ CbcPointer<PeerPoolMgr> mgr; ///< pool manager
+ int limit = 0; ///< the limit itself
+ bool waitingForClose = false; ///< a conn must close before we open a standby conn
+ } standby;
+
+ char *domain = nullptr; ///< Forced domain
/// security settings for peer connection
Security::PeerOptions secure;
Security::ContextPointer sslContext;
Security::SessionStatePointer sslSession;
- int front_end_https;
- int connection_auth;
+ int front_end_https = 0; ///< 0 - off, 1 - on, 2 - auto
+ int connection_auth = 2; ///< 0 - off, 1 - on, 2 - auto
};
#endif /* SQUID_CACHEPEER_H_ */