]> git.ipfire.org Git - thirdparty/squid.git/blame - src/CachePeer.cc
Remove --enable-kill-parent-hack (#1178)
[thirdparty/squid.git] / src / CachePeer.cc
CommitLineData
719815a0 1/*
bf95c10a 2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
719815a0
AJ
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"
719815a0
AJ
12#include "defines.h"
13#include "NeighborTypeDomainList.h"
14#include "pconn.h"
15#include "PeerPoolMgr.h"
5f5d319e 16#include "SquidConfig.h"
a555a85b 17#include "util.h"
719815a0
AJ
18
19CBDATA_CLASS_INIT(CachePeer);
20
a555a85b
AR
21CachePeer::CachePeer(const char * const hostname):
22 name(xstrdup(hostname)),
23 host(xstrdup(hostname))
24{
25 Tolower(host); // but .name preserves original spelling
26}
27
719815a0
AJ
28CachePeer::~CachePeer()
29{
30 xfree(name);
31 xfree(host);
32
719815a0
AJ
33 while (NeighborTypeDomainList *l = typelist) {
34 typelist = l->next;
35 xfree(l->domain);
36 xfree(l);
37 }
38
39 aclDestroyAccessList(&access);
40
41#if USE_CACHE_DIGESTS
42 cbdataReferenceDone(digest);
43 xfree(digest_url);
44#endif
45
46 delete next;
47
48 xfree(login);
49
50 delete standby.pool;
51
52 // the mgr job will notice that its owner is gone and stop
53 PeerPoolMgr::Checkpoint(standby.mgr, "peer gone");
54
55 xfree(domain);
719815a0 56}
7dfc5092 57
a555a85b
AR
58void
59CachePeer::rename(const char * const newName)
60{
61 if (!newName || !*newName)
62 throw TextException("cache_peer name=value cannot be empty", Here());
63
64 xfree(name);
65 name = xstrdup(newName);
66}
67
5f5d319e
FC
68time_t
69CachePeer::connectTimeout() const
70{
71 if (connect_timeout_raw > 0)
72 return connect_timeout_raw;
73 return Config.Timeout.peer_connect;
74}
75
a555a85b
AR
76std::ostream &
77operator <<(std::ostream &os, const CachePeer &p)
78{
79 return os << p.name;
80}
81