CommCalls.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #include "squid.h"
10 #include "anyp/PortCfg.h"
11 #include "comm/Connection.h"
12 #include "CommCalls.h"
13 #include "fde.h"
14 #include "globals.h"
15 
16 /* CommCommonCbParams */
17 
19  data(cbdataReference(aData)), conn(), flag(Comm::OK), xerrno(0), fd(-1)
20 {
21 }
22 
24  data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd)
25 {
26 }
27 
29 {
31 }
32 
33 void
34 CommCommonCbParams::print(std::ostream &os) const
35 {
36  if (conn != NULL)
37  os << conn;
38  else
39  os << "FD " << fd;
40 
41  if (xerrno)
42  os << ", errno=" << xerrno;
43  if (flag != Comm::OK)
44  os << ", flag=" << flag;
45  if (data)
46  os << ", data=" << data;
47 }
48 
49 /* CommAcceptCbParams */
50 
52  CommCommonCbParams(aData), xaction()
53 {
54 }
55 
56 void
57 CommAcceptCbParams::print(std::ostream &os) const
58 {
60 
61  if (xaction != NULL)
62  os << ", " << xaction->id;
63 }
64 
65 /* CommConnectCbParams */
66 
68  CommCommonCbParams(aData)
69 {
70 }
71 
72 bool
74 {
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);
79  return false;
80  }
81  return true; // now we are in sync and can handle the call
82 }
83 
84 /* CommIoCbParams */
85 
87  buf(NULL), size(0)
88 {
89 }
90 
91 bool
93 {
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);
99  }
100  return true; // now we are in sync and can handle the call
101 }
102 
103 void
104 CommIoCbParams::print(std::ostream &os) const
105 {
107  if (buf) {
108  os << ", size=" << size;
109  os << ", buf=" << (void*)buf;
110  }
111 }
112 
113 /* CommCloseCbParams */
114 
116  CommCommonCbParams(aData)
117 {
118 }
119 
120 /* CommTimeoutCbParams */
121 
123  CommCommonCbParams(aData)
124 {
125 }
126 
127 /* FdeCbParams */
128 
130  CommCommonCbParams(aData)
131 {
132 }
133 
134 /* CommAcceptCbPtrFun */
135 
137  const CommAcceptCbParams &aParams):
139  handler(aHandler)
140 {
141 }
142 
145  handler(o.handler)
146 {
147 }
148 
149 void
151 {
152  handler(params);
153 }
154 
155 void
156 CommAcceptCbPtrFun::print(std::ostream &os) const
157 {
158  os << '(';
159  params.print(os);
160  os << ')';
161 }
162 
163 /* CommConnectCbPtrFun */
164 
166  const CommConnectCbParams &aParams):
168  handler(aHandler)
169 {
170 }
171 
172 void
174 {
176 }
177 
178 void
179 CommConnectCbPtrFun::print(std::ostream &os) const
180 {
181  os << '(';
182  params.print(os);
183  os << ')';
184 }
185 
186 /* CommIoCbPtrFun */
187 
190  handler(aHandler)
191 {
192 }
193 
194 void
196 {
198 }
199 
200 void
201 CommIoCbPtrFun::print(std::ostream &os) const
202 {
203  os << '(';
204  params.print(os);
205  os << ')';
206 }
207 
208 /* CommCloseCbPtrFun */
209 
211  const CommCloseCbParams &aParams):
213  handler(aHandler)
214 {
215 }
216 
217 void
219 {
220  handler(params);
221 }
222 
223 void
224 CommCloseCbPtrFun::print(std::ostream &os) const
225 {
226  os << '(';
227  params.print(os);
228  os << ')';
229 }
230 
231 /* CommTimeoutCbPtrFun */
232 
234  const CommTimeoutCbParams &aParams):
236  handler(aHandler)
237 {
238 }
239 
240 void
242 {
243  handler(params);
244 }
245 
246 void
247 CommTimeoutCbPtrFun::print(std::ostream &os) const
248 {
249  os << '(';
250  params.print(os);
251  os << ')';
252 }
253 
254 /* FdeCbPtrFun */
255 
256 FdeCbPtrFun::FdeCbPtrFun(FDECB *aHandler, const FdeCbParams &aParams) :
257  CommDialerParamsT<FdeCbParams>(aParams),
258  handler(aHandler)
259 {
260 }
261 
262 void
264 {
265  handler(params);
266 }
267 
268 void
269 FdeCbPtrFun::print(std::ostream &os) const
270 {
271  os << '(';
272  params.print(os);
273  os << ')';
274 }
275 
bool syncWithComm()
Definition: CommCalls.cc:92
#define fd_table
Definition: fde.h:157
CommIoCbParams(void *aData)
Definition: CommCalls.cc:86
void print(std::ostream &os) const
Definition: CommCalls.cc:104
#define cbdataReferenceDone(var)
Definition: cbdata.h:350
void CTCB(const CommTimeoutCbParams &params)
Definition: CommCalls.h:39
CommCommonCbParams(void *aData)
Definition: CommCalls.cc:18
Definition: Flag.h:16
FdeCbParams(void *aData)
Definition: CommCalls.cc:129
CommConnectCbParams(void *aData)
Definition: CommCalls.cc:67
char * p
Definition: membanger.c:43
int conn
the current server connection FD
Definition: Transport.cc:26
CommCloseCbParams(void *aData)
Definition: CommCalls.cc:115
CommAcceptCbParams(void *aData)
Definition: CommCalls.cc:51
void IOACB(const CommAcceptCbParams &params)
Definition: CommCalls.h:33
Comm::ConnectionPointer conn
Definition: CommCalls.h:85
InstanceId< MasterXaction > id
transaction ID.
Definition: MasterXaction.h:44
void const char HLPCB void * data
Definition: stub_helper.cc:16
int fd
FD which the call was about. Set by the async call creator.
Definition: CommCalls.h:90
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
#define cbdataReference(var)
Definition: cbdata.h:341
void dial()
Definition: CommCalls.cc:263
CommTimeoutCbParams(void *aData)
Definition: CommCalls.cc:122
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:201
FdeCbPtrFun(FDECB *aHandler, const Params &aParams)
Definition: CommCalls.cc:256
int xerrno
The last errno to occur. non-zero if flag is Comm::COMM_ERROR.
Definition: CommCalls.h:88
void print(std::ostream &os) const
Definition: CommCalls.cc:57
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:247
CommConnectCbPtrFun(CNCB *aHandler, const Params &aParams)
Definition: CommCalls.cc:165
static void handler(int signo)
Definition: purge.cc:860
void CLCB(const CommCloseCbParams &params)
Definition: CommCalls.h:42
void const char * buf
Definition: stub_helper.cc:16
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:147
void IOCB(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag flag, int xerrno, void *data)
Definition: CommCalls.h:36
MasterXaction::Pointer xaction
Transaction which this call is part of.
Definition: CommCalls.h:105
CommTimeoutCbPtrFun(CTCB *aHandler, const Params &aParams)
Definition: CommCalls.cc:233
Comm::Flag flag
comm layer result status.
Definition: CommCalls.h:87
CommAcceptCbPtrFun(IOACB *aHandler, const CommAcceptCbParams &aParams)
Definition: CommCalls.cc:136
FDECB * handler
Definition: CommCalls.h:302
IOCB * handler
Definition: CommCalls.h:256
void CNCB(const Comm::ConnectionPointer &conn, Comm::Flag status, int xerrno, void *data)
Definition: CommCalls.h:35
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:156
CommCloseCbPtrFun(CLCB *aHandler, const Params &aParams)
Definition: CommCalls.cc:210
void print(std::ostream &os) const
Definition: CommCalls.cc:34
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:224
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:179
virtual void print(std::ostream &os) const
Definition: CommCalls.cc:269
#define NULL
Definition: types.h:166
void FDECB(const FdeCbParams &params)
Definition: CommCalls.h:45
int size
Definition: ModDevPoll.cc:77
CommIoCbPtrFun(IOCB *aHandler, const Params &aParams)
Definition: CommCalls.cc:188

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors