]>
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
;
50 os
<< ", " << details
;
54 /* CommConnectCbParams */
56 CommConnectCbParams::CommConnectCbParams(void *aData
):
57 CommCommonCbParams(aData
)
62 CommConnectCbParams::syncWithComm()
64 // drop the call if the call was scheduled before comm_close but
65 // is being fired after comm_close
66 if (fd
>= 0 && fd_table
[fd
].closing()) {
67 debugs(5, 3, HERE
<< "dropping late connect call: FD " << fd
);
70 return true; // now we are in sync and can handle the call
74 CommConnectCbParams::print(std::ostream
&os
) const
76 CommCommonCbParams::print(os
);
83 CommIoCbParams::CommIoCbParams(void *aData
): CommCommonCbParams(aData
),
89 CommIoCbParams::syncWithComm()
91 // change parameters if the call was scheduled before comm_close but
92 // is being fired after comm_close
93 if (fd
>= 0 && fd_table
[fd
].closing() && flag
!= COMM_ERR_CLOSING
) {
94 debugs(5, 3, HERE
<< "converting late call to COMM_ERR_CLOSING: FD " << fd
);
95 flag
= COMM_ERR_CLOSING
;
98 return true; // now we are in sync and can handle the call
103 CommIoCbParams::print(std::ostream
&os
) const
105 CommCommonCbParams::print(os
);
107 os
<< ", size=" << size
;
108 os
<< ", buf=" << (void*)buf
;
113 /* CommCloseCbParams */
115 CommCloseCbParams::CommCloseCbParams(void *aData
):
116 CommCommonCbParams(aData
)
120 /* CommTimeoutCbParams */
122 CommTimeoutCbParams::CommTimeoutCbParams(void *aData
):
123 CommCommonCbParams(aData
)
128 /* CommAcceptCbPtrFun */
130 CommAcceptCbPtrFun::CommAcceptCbPtrFun(IOACB
*aHandler
,
131 const CommAcceptCbParams
&aParams
):
132 CommDialerParamsT
<CommAcceptCbParams
>(aParams
),
138 CommAcceptCbPtrFun::dial()
140 handler(params
.fd
, params
.nfd
, params
.details
, params
.flag
, params
.xerrno
, params
.data
);
144 CommAcceptCbPtrFun::print(std::ostream
&os
) const
152 /* CommConnectCbPtrFun */
154 CommConnectCbPtrFun::CommConnectCbPtrFun(CNCB
*aHandler
,
155 const CommConnectCbParams
&aParams
):
156 CommDialerParamsT
<CommConnectCbParams
>(aParams
),
162 CommConnectCbPtrFun::dial()
164 handler(params
.conn
, params
.flag
, params
.xerrno
, params
.data
);
168 CommConnectCbPtrFun::print(std::ostream
&os
) const
178 CommIoCbPtrFun::CommIoCbPtrFun(IOCB
*aHandler
, const CommIoCbParams
&aParams
):
179 CommDialerParamsT
<CommIoCbParams
>(aParams
),
185 CommIoCbPtrFun::dial()
187 handler(params
.fd
, params
.buf
, params
.size
, params
.flag
, params
.xerrno
, params
.data
);
191 CommIoCbPtrFun::print(std::ostream
&os
) const
199 /* CommCloseCbPtrFun */
201 CommCloseCbPtrFun::CommCloseCbPtrFun(PF
*aHandler
,
202 const CommCloseCbParams
&aParams
):
203 CommDialerParamsT
<CommCloseCbParams
>(aParams
),
209 CommCloseCbPtrFun::dial()
211 handler(params
.fd
, params
.data
);
215 CommCloseCbPtrFun::print(std::ostream
&os
) const
222 /* CommTimeoutCbPtrFun */
224 CommTimeoutCbPtrFun::CommTimeoutCbPtrFun(PF
*aHandler
,
225 const CommTimeoutCbParams
&aParams
):
226 CommDialerParamsT
<CommTimeoutCbParams
>(aParams
),
232 CommTimeoutCbPtrFun::dial()
234 handler(params
.fd
, params
.data
);
238 CommTimeoutCbPtrFun::print(std::ostream
&os
) const