1 /*
2 * Copyright (C) 1996-2021 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 #include "squid.h"
10 #include "acl/Gadgets.h"
11 #include "CachePeer.h"
12 #include "defines.h"
13 #include "NeighborTypeDomainList.h"
14 #include "pconn.h"
15 #include "PeerPoolMgr.h"
16
17 CBDATA_CLASS_INIT(CachePeer);
18
CachePeer()19 CachePeer::CachePeer() :
20 index(0),
21 name(NULL),
22 host(NULL),
23 type(PEER_NONE),
24 http_port(CACHE_HTTP_PORT),
25 typelist(NULL),
26 access(NULL),
27 weight(1),
28 basetime(0),
29 #if USE_CACHE_DIGESTS
30 digest(NULL),
31 digest_url(NULL),
32 #endif
33 tcp_up(0),
34 reprobe(false),
35 n_addresses(0),
36 rr_count(0),
37 next(NULL),
38 testing_now(false),
39 login(NULL),
40 connect_timeout_raw(0),
41 connect_fail_limit(0),
42 max_conn(0),
43 domain(NULL),
44 front_end_https(0),
45 connection_auth(2 /* auto */)
46 {
47 memset(&stats, 0, sizeof(stats));
48 stats.logged_state = PEER_ALIVE;
49
50 memset(&icp, 0, sizeof(icp));
51 icp.port = CACHE_ICP_PORT;
52 icp.version = ICP_VERSION_CURRENT;
53
54 #if USE_HTCP
55 memset(&htcp, 0, sizeof(htcp));
56 #endif
57 memset(&options, 0, sizeof(options));
58 memset(&mcast, 0, sizeof(mcast));
59 memset(&carp, 0, sizeof(carp));
60 #if USE_AUTH
61 memset(&userhash, 0, sizeof(userhash));
62 #endif
63 memset(&sourcehash, 0, sizeof(sourcehash));
64
65 standby.pool = NULL;
66 standby.limit = 0;
67 standby.waitingForClose = false;
68 }
69
~CachePeer()70 CachePeer::~CachePeer()
71 {
72 xfree(name);
73 xfree(host);
74
75 while (NeighborTypeDomainList *l = typelist) {
76 typelist = l->next;
77 xfree(l->domain);
78 xfree(l);
79 }
80
81 aclDestroyAccessList(&access);
82
83 #if USE_CACHE_DIGESTS
84 cbdataReferenceDone(digest);
85 xfree(digest_url);
86 #endif
87
88 delete next;
89
90 xfree(login);
91
92 delete standby.pool;
93
94 // the mgr job will notice that its owner is gone and stop
95 PeerPoolMgr::Checkpoint(standby.mgr, "peer gone");
96
97 xfree(domain);
98 }
99
100