]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/CommCalls.cc
3 #include "comm/Connection.h"
6 /* CommCommonCbParams */
8 CommCommonCbParams::CommCommonCbParams(void *aData
):
9 data(cbdataReference(aData
)), fd(-1), xerrno(0), flag(COMM_OK
)
13 CommCommonCbParams::CommCommonCbParams(const CommCommonCbParams
&p
):
14 data(cbdataReference(p
.data
)), fd(p
.fd
), xerrno(p
.xerrno
), flag(p
.flag
)
18 CommCommonCbParams::~CommCommonCbParams()
20 cbdataReferenceDone(data
);
24 CommCommonCbParams::print(std::ostream
&os
) const
28 os
<< ", errno=" << xerrno
;
30 os
<< ", flag=" << flag
;
32 os
<< ", data=" << data
;
36 /* CommAcceptCbParams */
38 CommAcceptCbParams::CommAcceptCbParams(void *aData
): CommCommonCbParams(aData
),
44 CommAcceptCbParams::print(std::ostream
&os
) const
46 CommCommonCbParams::print(os
);
48 os
<< ", newFD " << nfd
;
49 os
<< ", " << details
;
53 /* CommConnectCbParams */
55 CommConnectCbParams::CommConnectCbParams(void *aData
):
56 CommCommonCbParams(aData
)
61 CommConnectCbParams::syncWithComm()
63 // drop the call if the call was scheduled before comm_close but
64 // is being fired after comm_close
65 if (fd
>= 0 && fd_table
[fd
].closing()) {
66 debugs(5, 3, HERE
<< "droppin late connect call: FD " << fd
);
69 return true; // now we are in sync and can handle the call
73 CommConnectCbParams::print(std::ostream
&os
) const
75 CommCommonCbParams::print(os
);
77 os
<< ", conn.local=" << conn
->local
<< ", conn.remote=" << conn
->remote
;
82 CommIoCbParams::CommIoCbParams(void *aData
): CommCommonCbParams(aData
),
88 CommIoCbParams::syncWithComm()
90 // change parameters if the call was scheduled before comm_close but
91 // is being fired after comm_close
92 if (fd
>= 0 && fd_table
[fd
].closing() && flag
!= COMM_ERR_CLOSING
) {
93 debugs(5, 3, HERE
<< "converting late call to COMM_ERR_CLOSING: FD " << fd
);
94 flag
= COMM_ERR_CLOSING
;
97 return true; // now we are in sync and can handle the call
102 CommIoCbParams::print(std::ostream
&os
) const
104 CommCommonCbParams::print(os
);
106 os
<< ", size=" << size
;
107 os
<< ", buf=" << (void*)buf
;
112 /* CommCloseCbParams */
114 CommCloseCbParams::CommCloseCbParams(void *aData
):
115 CommCommonCbParams(aData
)
119 /* CommTimeoutCbParams */
121 CommTimeoutCbParams::CommTimeoutCbParams(void *aData
):
122 CommCommonCbParams(aData
)
127 /* CommAcceptCbPtrFun */
129 CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB
*aHandler
,
130 const CommAcceptCbParams
&aParams
):
131 CommDialerParamsT
<CommAcceptCbParams
>(aParams
),
137 CommAcceptCbPtrFun::dial()
139 handler(params
.fd
, params
.nfd
, params
.details
, params
.flag
, params
.xerrno
, params
.data
);
143 CommAcceptCbPtrFun::print(std::ostream
&os
) const
151 /* CommConnectCbPtrFun */
153 CommConnectCbPtrFun::CommConnectCbPtrFun(CNCB
*aHandler
,
154 const CommConnectCbParams
&aParams
):
155 CommDialerParamsT
<CommConnectCbParams
>(aParams
),
161 CommConnectCbPtrFun::dial()
163 handler(params
.conn
, params
.flag
, params
.xerrno
, params
.data
);
167 CommConnectCbPtrFun::print(std::ostream
&os
) const
177 CommIoCbPtrFun::CommIoCbPtrFun(IOCB
*aHandler
, const CommIoCbParams
&aParams
):
178 CommDialerParamsT
<CommIoCbParams
>(aParams
),
184 CommIoCbPtrFun::dial()
186 handler(params
.fd
, params
.buf
, params
.size
, params
.flag
, params
.xerrno
, params
.data
);
190 CommIoCbPtrFun::print(std::ostream
&os
) const
198 /* CommCloseCbPtrFun */
200 CommCloseCbPtrFun::CommCloseCbPtrFun(PF
*aHandler
,
201 const CommCloseCbParams
&aParams
):
202 CommDialerParamsT
<CommCloseCbParams
>(aParams
),
208 CommCloseCbPtrFun::dial()
210 handler(params
.fd
, params
.data
);
214 CommCloseCbPtrFun::print(std::ostream
&os
) const
221 /* CommTimeoutCbPtrFun */
223 CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(PF
*aHandler
,
224 const CommTimeoutCbParams
&aParams
):
225 CommDialerParamsT
<CommTimeoutCbParams
>(aParams
),
231 CommTimeoutCbPtrFun::dial()
233 handler(params
.fd
, params
.data
);
237 CommTimeoutCbPtrFun::print(std::ostream
&os
) const