]> git.ipfire.org Git - thirdparty/squid.git/blame - src/CommCalls.cc
Removed squid-old.h
[thirdparty/squid.git] / src / CommCalls.cc
CommitLineData
582c2af2 1#include "squid.h"
f9b72e0c 2#include "comm/Connection.h"
b0469965 3#include "CommCalls.h"
582c2af2
FC
4#include "fde.h"
5#include "globals.h"
b0469965 6
7/* CommCommonCbParams */
8
9CommCommonCbParams::CommCommonCbParams(void *aData):
3e4bebf8 10 data(cbdataReference(aData)), conn(), flag(COMM_OK), xerrno(0), fd(-1)
b0469965 11{
12}
13
14CommCommonCbParams::CommCommonCbParams(const CommCommonCbParams &p):
3e4bebf8 15 data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd)
b0469965 16{
17}
18
19CommCommonCbParams::~CommCommonCbParams()
20{
21 cbdataReferenceDone(data);
22}
23
24void
25CommCommonCbParams::print(std::ostream &os) const
26{
7957e704
AJ
27 if (conn != NULL)
28 os << conn;
29 else
30 os << "FD " << fd;
31
b0469965 32 if (xerrno)
33 os << ", errno=" << xerrno;
34 if (flag != COMM_OK)
35 os << ", flag=" << flag;
36 if (data)
37 os << ", data=" << data;
38}
39
40
41/* CommAcceptCbParams */
42
b9ddfca2
AJ
43CommAcceptCbParams::CommAcceptCbParams(void *aData):
44 CommCommonCbParams(aData)
b0469965 45{
46}
47
b0469965 48/* CommConnectCbParams */
49
50CommConnectCbParams::CommConnectCbParams(void *aData):
26ac0430 51 CommCommonCbParams(aData)
b0469965 52{
53}
54
4c3ba68d
AR
55bool
56CommConnectCbParams::syncWithComm()
57{
58 // drop the call if the call was scheduled before comm_close but
59 // is being fired after comm_close
60 if (fd >= 0 && fd_table[fd].closing()) {
2aecafa9 61 debugs(5, 3, HERE << "dropping late connect call: FD " << fd);
4c3ba68d
AR
62 return false;
63 }
64 return true; // now we are in sync and can handle the call
65}
b0469965 66
67/* CommIoCbParams */
68
69CommIoCbParams::CommIoCbParams(void *aData): CommCommonCbParams(aData),
26ac0430 70 buf(NULL), size(0)
b0469965 71{
72}
73
4c3ba68d 74bool
82ec8dfc
AR
75CommIoCbParams::syncWithComm()
76{
77 // change parameters if the call was scheduled before comm_close but
78 // is being fired after comm_close
68077594 79 if ((conn->fd < 0 || fd_table[conn->fd].closing()) && flag != COMM_ERR_CLOSING) {
a138c8fc 80 debugs(5, 3, HERE << "converting late call to COMM_ERR_CLOSING: " << conn);
26ac0430 81 flag = COMM_ERR_CLOSING;
82ec8dfc 82 }
4c3ba68d 83 return true; // now we are in sync and can handle the call
26ac0430 84}
82ec8dfc
AR
85
86
b0469965 87void
88CommIoCbParams::print(std::ostream &os) const
89{
90 CommCommonCbParams::print(os);
91 if (buf) {
92 os << ", size=" << size;
93 os << ", buf=" << (void*)buf;
26ac0430 94 }
b0469965 95}
96
97
98/* CommCloseCbParams */
99
100CommCloseCbParams::CommCloseCbParams(void *aData):
26ac0430 101 CommCommonCbParams(aData)
b0469965 102{
103}
104
105/* CommTimeoutCbParams */
106
107CommTimeoutCbParams::CommTimeoutCbParams(void *aData):
26ac0430 108 CommCommonCbParams(aData)
b0469965 109{
110}
111
a17bf806
AJ
112/* FdeCbParams */
113
114FdeCbParams::FdeCbParams(void *aData):
115 CommCommonCbParams(aData)
116{
117}
80463bb4 118
b0469965 119/* CommAcceptCbPtrFun */
120
121CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB *aHandler,
26ac0430
AJ
122 const CommAcceptCbParams &aParams):
123 CommDialerParamsT<CommAcceptCbParams>(aParams),
124 handler(aHandler)
b0469965 125{
126}
127
b9ddfca2
AJ
128CommAcceptCbPtrFun::CommAcceptCbPtrFun(const CommAcceptCbPtrFun &o):
129 CommDialerParamsT<CommAcceptCbParams>(o.params),
130 handler(o.handler)
131{
132}
133
b0469965 134void
135CommAcceptCbPtrFun::dial()
136{
449f0115 137 handler(params);
b0469965 138}
139
140void
141CommAcceptCbPtrFun::print(std::ostream &os) const
142{
143 os << '(';
144 params.print(os);
145 os << ')';
146}
147
148
149/* CommConnectCbPtrFun */
150
151CommConnectCbPtrFun::CommConnectCbPtrFun(CNCB *aHandler,
26ac0430
AJ
152 const CommConnectCbParams &aParams):
153 CommDialerParamsT<CommConnectCbParams>(aParams),
154 handler(aHandler)
b0469965 155{
156}
157
158void
159CommConnectCbPtrFun::dial()
160{
aed188fd 161 handler(params.conn, params.flag, params.xerrno, params.data);
b0469965 162}
163
164void
165CommConnectCbPtrFun::print(std::ostream &os) const
166{
167 os << '(';
168 params.print(os);
169 os << ')';
170}
171
172
173/* CommIoCbPtrFun */
174
175CommIoCbPtrFun::CommIoCbPtrFun(IOCB *aHandler, const CommIoCbParams &aParams):
26ac0430
AJ
176 CommDialerParamsT<CommIoCbParams>(aParams),
177 handler(aHandler)
b0469965 178{
179}
180
181void
182CommIoCbPtrFun::dial()
183{
a138c8fc 184 handler(params.conn, params.buf, params.size, params.flag, params.xerrno, params.data);
b0469965 185}
186
187void
188CommIoCbPtrFun::print(std::ostream &os) const
189{
190 os << '(';
191 params.print(os);
192 os << ')';
193}
194
195
196/* CommCloseCbPtrFun */
197
575d05c4 198CommCloseCbPtrFun::CommCloseCbPtrFun(CLCB *aHandler,
26ac0430
AJ
199 const CommCloseCbParams &aParams):
200 CommDialerParamsT<CommCloseCbParams>(aParams),
201 handler(aHandler)
b0469965 202{
203}
204
205void
206CommCloseCbPtrFun::dial()
207{
575d05c4 208 handler(params);
b0469965 209}
210
211void
212CommCloseCbPtrFun::print(std::ostream &os) const
213{
214 os << '(';
215 params.print(os);
216 os << ')';
217}
218
219/* CommTimeoutCbPtrFun */
220
8d77a37c 221CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(CTCB *aHandler,
26ac0430
AJ
222 const CommTimeoutCbParams &aParams):
223 CommDialerParamsT<CommTimeoutCbParams>(aParams),
224 handler(aHandler)
b0469965 225{
226}
227
228void
229CommTimeoutCbPtrFun::dial()
230{
8d77a37c 231 handler(params);
b0469965 232}
233
234void
235CommTimeoutCbPtrFun::print(std::ostream &os) const
236{
237 os << '(';
238 params.print(os);
239 os << ')';
240}
a17bf806
AJ
241
242/* FdeCbPtrFun */
243
244FdeCbPtrFun::FdeCbPtrFun(FDECB *aHandler, const FdeCbParams &aParams) :
245 CommDialerParamsT<FdeCbParams>(aParams),
246 handler(aHandler)
247{
248}
249
250void
251FdeCbPtrFun::dial()
252{
253 handler(params);
254}
255
256void
257FdeCbPtrFun::print(std::ostream &os) const
258{
259 os << '(';
260 params.print(os);
261 os << ')';
262}