]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/CommCalls.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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.
10 #include "anyp/PortCfg.h"
11 #include "comm/Connection.h"
12 #include "CommCalls.h"
16 /* CommCommonCbParams */
18 CommCommonCbParams::CommCommonCbParams(void *aData
):
19 data(cbdataReference(aData
)), conn(), flag(Comm::OK
), xerrno(0), fd(-1)
23 CommCommonCbParams::CommCommonCbParams(const CommCommonCbParams
&p
):
24 data(cbdataReference(p
.data
)), conn(p
.conn
), flag(p
.flag
), xerrno(p
.xerrno
), fd(p
.fd
)
28 CommCommonCbParams::~CommCommonCbParams()
30 cbdataReferenceDone(data
);
34 CommCommonCbParams::print(std::ostream
&os
) const
42 os
<< ", errno=" << xerrno
;
44 os
<< ", flag=" << flag
;
46 os
<< ", data=" << data
;
49 /* CommAcceptCbParams */
51 CommAcceptCbParams::CommAcceptCbParams(void *aData
):
52 CommCommonCbParams(aData
), xaction()
57 CommAcceptCbParams::print(std::ostream
&os
) const
59 CommCommonCbParams::print(os
);
62 os
<< ", " << xaction
->id
;
65 /* CommConnectCbParams */
67 CommConnectCbParams::CommConnectCbParams(void *aData
):
68 CommCommonCbParams(aData
)
73 CommConnectCbParams::syncWithComm()
75 // drop the call if the call was scheduled before comm_close but
76 // is being fired after comm_close
77 if (fd
>= 0 && fd_table
[fd
].closing()) {
78 debugs(5, 3, HERE
<< "dropping late connect call: FD " << fd
);
81 return true; // now we are in sync and can handle the call
86 CommIoCbParams::CommIoCbParams(void *aData
): CommCommonCbParams(aData
),
92 CommIoCbParams::syncWithComm()
94 // change parameters if the call was scheduled before comm_close but
95 // is being fired after comm_close
96 if ((conn
->fd
< 0 || fd_table
[conn
->fd
].closing()) && flag
!= Comm::ERR_CLOSING
) {
97 debugs(5, 3, HERE
<< "converting late call to Comm::ERR_CLOSING: " << conn
);
98 flag
= Comm::ERR_CLOSING
;
100 return true; // now we are in sync and can handle the call
104 CommIoCbParams::print(std::ostream
&os
) const
106 CommCommonCbParams::print(os
);
108 os
<< ", size=" << size
;
109 os
<< ", buf=" << (void*)buf
;
113 /* CommCloseCbParams */
115 CommCloseCbParams::CommCloseCbParams(void *aData
):
116 CommCommonCbParams(aData
)
120 /* CommTimeoutCbParams */
122 CommTimeoutCbParams::CommTimeoutCbParams(void *aData
):
123 CommCommonCbParams(aData
)
129 FdeCbParams::FdeCbParams(void *aData
):
130 CommCommonCbParams(aData
)
134 /* CommAcceptCbPtrFun */
136 CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB
*aHandler
,
137 const CommAcceptCbParams
&aParams
):
138 CommDialerParamsT
<CommAcceptCbParams
>(aParams
),
143 CommAcceptCbPtrFun::CommAcceptCbPtrFun(const CommAcceptCbPtrFun
&o
):
144 CommDialerParamsT
<CommAcceptCbParams
>(o
.params
),
150 CommAcceptCbPtrFun::dial()
156 CommAcceptCbPtrFun::print(std::ostream
&os
) const
163 /* CommConnectCbPtrFun */
165 CommConnectCbPtrFun::CommConnectCbPtrFun(CNCB
*aHandler
,
166 const CommConnectCbParams
&aParams
):
167 CommDialerParamsT
<CommConnectCbParams
>(aParams
),
173 CommConnectCbPtrFun::dial()
175 handler(params
.conn
, params
.flag
, params
.xerrno
, params
.data
);
179 CommConnectCbPtrFun::print(std::ostream
&os
) const
188 CommIoCbPtrFun::CommIoCbPtrFun(IOCB
*aHandler
, const CommIoCbParams
&aParams
):
189 CommDialerParamsT
<CommIoCbParams
>(aParams
),
195 CommIoCbPtrFun::dial()
197 handler(params
.conn
, params
.buf
, params
.size
, params
.flag
, params
.xerrno
, params
.data
);
201 CommIoCbPtrFun::print(std::ostream
&os
) const
208 /* CommCloseCbPtrFun */
210 CommCloseCbPtrFun::CommCloseCbPtrFun(CLCB
*aHandler
,
211 const CommCloseCbParams
&aParams
):
212 CommDialerParamsT
<CommCloseCbParams
>(aParams
),
218 CommCloseCbPtrFun::dial()
224 CommCloseCbPtrFun::print(std::ostream
&os
) const
231 /* CommTimeoutCbPtrFun */
233 CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(CTCB
*aHandler
,
234 const CommTimeoutCbParams
&aParams
):
235 CommDialerParamsT
<CommTimeoutCbParams
>(aParams
),
241 CommTimeoutCbPtrFun::dial()
247 CommTimeoutCbPtrFun::print(std::ostream
&os
) const
256 FdeCbPtrFun::FdeCbPtrFun(FDECB
*aHandler
, const FdeCbParams
&aParams
) :
257 CommDialerParamsT
<FdeCbParams
>(aParams
),
269 FdeCbPtrFun::print(std::ostream
&os
) const