]> git.ipfire.org Git - thirdparty/squid.git/blame - src/acl/FilledChecklist.cc
Bug 3615: configure check for default max number of FDs is broken
[thirdparty/squid.git] / src / acl / FilledChecklist.cc
CommitLineData
582c2af2
FC
1#include "squid.h"
2#include "acl/FilledChecklist.h"
351fe86d 3#include "client_side.h"
582c2af2
FC
4#include "comm/Connection.h"
5#include "comm/forward.h"
6#include "HttpReply.h"
7#include "HttpRequest.h"
2f1431ea 8#if USE_AUTH
351fe86d
AR
9#include "auth/UserRequest.h"
10#include "auth/AclProxyAuth.h"
2f1431ea 11#endif
582c2af2 12
351fe86d
AR
13CBDATA_CLASS_INIT(ACLFilledChecklist);
14
351fe86d
AR
15void *
16ACLFilledChecklist::operator new (size_t size)
17{
18 assert (size == sizeof(ACLFilledChecklist));
19 CBDATA_INIT_TYPE(ACLFilledChecklist);
20 ACLFilledChecklist *result = cbdataAlloc(ACLFilledChecklist);
21 return result;
22}
23
24void
25ACLFilledChecklist::operator delete (void *address)
26{
27 ACLFilledChecklist *t = static_cast<ACLFilledChecklist *>(address);
28 cbdataFree(t);
29}
30
351fe86d
AR
31ACLFilledChecklist::ACLFilledChecklist() :
32 dst_peer(NULL),
12ef783b 33 dst_rdns(NULL),
351fe86d
AR
34 request (NULL),
35 reply (NULL),
2f1431ea 36#if USE_AUTH
351fe86d 37 auth_user_request (NULL),
2f1431ea 38#endif
351fe86d
AR
39#if SQUID_SNMP
40 snmp_community(NULL),
351fe86d 41#endif
fa24d749 42#if USE_SSL
7a957a93 43 sslErrors(NULL),
fa24d749 44#endif
351fe86d
AR
45 extacl_entry (NULL),
46 conn_(NULL),
47 fd_(-1),
48 destinationDomainChecked_(false),
49 sourceDomainChecked_(false)
50{
51 my_addr.SetEmpty();
52 src_addr.SetEmpty();
53 dst_addr.SetEmpty();
54 rfc931[0] = '\0';
55}
56
351fe86d
AR
57ACLFilledChecklist::~ACLFilledChecklist()
58{
59 assert (!asyncInProgress());
60
12ef783b
AJ
61 safe_free(dst_rdns); // created by xstrdup().
62
351fe86d
AR
63 if (extacl_entry)
64 cbdataReferenceDone(extacl_entry);
65
66 HTTPMSGUNLOCK(request);
67
68 HTTPMSGUNLOCK(reply);
69
351fe86d
AR
70 cbdataReferenceDone(conn_);
71
fa24d749 72#if USE_SSL
7a957a93 73 cbdataReferenceDone(sslErrors);
fa24d749 74#endif
4fb72cb9 75
351fe86d
AR
76 debugs(28, 4, HERE << "ACLFilledChecklist destroyed " << this);
77}
78
351fe86d
AR
79ConnStateData *
80ACLFilledChecklist::conn() const
81{
82 return conn_;
83}
84
85void
86ACLFilledChecklist::conn(ConnStateData *aConn)
87{
16a16ffe
CT
88 if (conn() == aConn)
89 return;
351fe86d
AR
90 assert (conn() == NULL);
91 conn_ = cbdataReference(aConn);
92}
93
94int
95ACLFilledChecklist::fd() const
96{
73c36fd9 97 return (conn_ != NULL && conn_->clientConnection != NULL) ? conn_->clientConnection->fd : fd_;
351fe86d
AR
98}
99
100void
101ACLFilledChecklist::fd(int aDescriptor)
102{
73c36fd9 103 assert(!conn() || conn()->clientConnection == NULL || conn()->clientConnection->fd == aDescriptor);
351fe86d
AR
104 fd_ = aDescriptor;
105}
106
107bool
108ACLFilledChecklist::destinationDomainChecked() const
109{
110 return destinationDomainChecked_;
111}
112
113void
114ACLFilledChecklist::markDestinationDomainChecked()
115{
116 assert (!finished() && !destinationDomainChecked());
117 destinationDomainChecked_ = true;
118}
119
120bool
121ACLFilledChecklist::sourceDomainChecked() const
122{
123 return sourceDomainChecked_;
124}
125
126void
127ACLFilledChecklist::markSourceDomainChecked()
128{
129 assert (!finished() && !sourceDomainChecked());
130 sourceDomainChecked_ = true;
131}
132
133/*
134 * There are two common ACLFilledChecklist lifecycles paths:
135 *
136 * A) Using aclCheckFast(): The caller creates an ACLFilledChecklist object
137 * on stack and calls aclCheckFast().
138 *
139 * B) Using aclNBCheck() and callbacks: The caller allocates an
140 * ACLFilledChecklist object (via operator new) and passes it to
141 * aclNBCheck(). Control eventually passes to ACLChecklist::checkCallback(),
142 * which will invoke the callback function as requested by the
143 * original caller of aclNBCheck(). This callback function must
144 * *not* delete the list. After the callback function returns,
145 * checkCallback() will delete the list (i.e., self).
146 */
f4462b38 147ACLFilledChecklist::ACLFilledChecklist(const acl_access *A, HttpRequest *http_request, const char *ident):
af6a12ee 148 dst_peer(NULL),
12ef783b 149 dst_rdns(NULL),
af6a12ee
AJ
150 request(NULL),
151 reply(NULL),
2f1431ea 152#if USE_AUTh
af6a12ee 153 auth_user_request(NULL),
2f1431ea 154#endif
351fe86d 155#if SQUID_SNMP
af6a12ee 156 snmp_community(NULL),
351fe86d 157#endif
fa24d749 158#if USE_SSL
7a957a93 159 sslErrors(NULL),
fa24d749 160#endif
af6a12ee
AJ
161 extacl_entry (NULL),
162 conn_(NULL),
163 fd_(-1),
164 destinationDomainChecked_(false),
165 sourceDomainChecked_(false)
351fe86d
AR
166{
167 my_addr.SetEmpty();
168 src_addr.SetEmpty();
169 dst_addr.SetEmpty();
170 rfc931[0] = '\0';
af6a12ee 171
351fe86d
AR
172 // cbdataReferenceDone() is in either fastCheck() or the destructor
173 if (A)
174 accessList = cbdataReference(A);
175
f4462b38
CT
176 if (http_request != NULL) {
177 request = HTTPMSGLOCK(http_request);
351fe86d
AR
178#if FOLLOW_X_FORWARDED_FOR
179 if (Config.onoff.acl_uses_indirect_client)
180 src_addr = request->indirect_client_addr;
181 else
182#endif /* FOLLOW_X_FORWARDED_FOR */
183 src_addr = request->client_addr;
184 my_addr = request->my_addr;
16a16ffe
CT
185
186 if (request->clientConnectionManager.valid())
187 conn(request->clientConnectionManager.get());
351fe86d
AR
188 }
189
190#if USE_IDENT
191 if (ident)
192 xstrncpy(rfc931, ident, USER_IDENT_SZ);
193#endif
194}
195