]> git.ipfire.org Git - thirdparty/squid.git/blob - src/CachePeer.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / CachePeer.cc
1 /*
2 * Copyright (C) 1996-2016 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
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 n_addresses(0),
35 rr_count(0),
36 next(NULL),
37 testing_now(false),
38 login(NULL),
39 connect_timeout(0),
40 connect_fail_limit(0),
41 max_conn(0),
42 domain(NULL),
43 #if USE_OPENSSL
44 sslContext(NULL),
45 sslSession(NULL),
46 #endif
47 front_end_https(0),
48 connection_auth(2 /* auto */)
49 {
50 memset(&stats, 0, sizeof(stats));
51 stats.logged_state = PEER_ALIVE;
52
53 memset(&icp, 0, sizeof(icp));
54 icp.port = CACHE_ICP_PORT;
55 icp.version = ICP_VERSION_CURRENT;
56
57 #if USE_HTCP
58 memset(&htcp, 0, sizeof(htcp));
59 #endif
60 memset(&options, 0, sizeof(options));
61 memset(&mcast, 0, sizeof(mcast));
62 memset(&carp, 0, sizeof(carp));
63 #if USE_AUTH
64 memset(&userhash, 0, sizeof(userhash));
65 #endif
66 memset(&sourcehash, 0, sizeof(sourcehash));
67
68 standby.pool = NULL;
69 standby.limit = 0;
70 standby.waitingForClose = false;
71 }
72
73 CachePeer::~CachePeer()
74 {
75 xfree(name);
76 xfree(host);
77
78 while (NeighborTypeDomainList *l = typelist) {
79 typelist = l->next;
80 xfree(l->domain);
81 xfree(l);
82 }
83
84 aclDestroyAccessList(&access);
85
86 #if USE_CACHE_DIGESTS
87 cbdataReferenceDone(digest);
88 xfree(digest_url);
89 #endif
90
91 delete next;
92
93 xfree(login);
94
95 delete standby.pool;
96
97 // the mgr job will notice that its owner is gone and stop
98 PeerPoolMgr::Checkpoint(standby.mgr, "peer gone");
99
100 xfree(domain);
101
102 #if USE_OPENSSL
103 if (sslContext)
104 SSL_CTX_free(sslContext);
105
106 if (sslSession)
107 SSL_SESSION_free(sslSession);
108 #endif
109 }
110