XRootD
Loading...
Searching...
No Matches
XrdXrootdResponse Class Reference

#include <XrdXrootdResponse.hh>

+ Collaboration diagram for XrdXrootdResponse:

Public Member Functions

 XrdXrootdResponse ()
 
 XrdXrootdResponse (XrdXrootdResponse &rhs)
 
 ~XrdXrootdResponse ()
 
const char * ID ()
 
bool isOurs ()
 
XrdXrootdResponseoperator= (const XrdXrootdResponse &rhs)
 
int Send (const char *msg)
 
int Send (int fdnum, long long offset, int dlen)
 
int Send (ServerResponseStatus &, int iLen, struct iovec *, int iovcnt, int iolen=-1)
 
int Send (ServerResponseStatus &, int iLen, void *data, int dlen)
 
int Send (ServerResponseStatus &, int iLen=0)
 
int Send (struct iovec *, int iovcnt, int iolen=-1)
 
int Send (void *data, int dlen)
 
int Send (void)
 
int Send (XErrorCode ecode, const char *msg)
 
int Send (XrdOucSFVec *sfvec, int sfvnum, int dlen)
 
int Send (XResponseType rcode, int info, const char *data, int dsz=-1)
 
int Send (XResponseType rcode, struct iovec *IOResp, int iornum, int iolen=-1)
 
int Send (XResponseType rcode, void *data, int dlen)
 
void Set (kXR_char *stream)
 
void Set (XrdLink *lp)
 
void Set (XrdXrootdTransit *tp)
 
void StreamID (kXR_char *sid)
 
XrdLinktheLink ()
 

Static Public Member Functions

static int Send (XrdXrootdReqID &ReqID, XResponseType Status, struct iovec *IOResp, int iornum, int iolen)
 

Detailed Description

Definition at line 48 of file XrdXrootdResponse.hh.

Constructor & Destructor Documentation

◆ XrdXrootdResponse() [1/2]

XrdXrootdResponse::XrdXrootdResponse ( XrdXrootdResponse & rhs)
inline

Definition at line 87 of file XrdXrootdResponse.hh.

87 {Set(rhs.Link);
88 Set(rhs.Bridge);
89 Set(rhs.Resp.streamid);
90 }
kXR_char streamid[2]
Definition XProtocol.hh:914
void Set(XrdLink *lp)

References XrdXrootdResponse(), Set(), and ServerResponseHeader::streamid.

Referenced by XrdXrootdResponse(), and operator=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ XrdXrootdResponse() [2/2]

XrdXrootdResponse::XrdXrootdResponse ( )
inline

Definition at line 92 of file XrdXrootdResponse.hh.

92 {Link = 0; Bridge = 0; *trsid = '\0';
93 RespIO[0].iov_base = (caddr_t)&Resp;
94 RespIO[0].iov_len = sizeof(Resp);
95 }

◆ ~XrdXrootdResponse()

XrdXrootdResponse::~XrdXrootdResponse ( )
inline

Definition at line 96 of file XrdXrootdResponse.hh.

96{}

Member Function Documentation

◆ ID()

const char * XrdXrootdResponse::ID ( )
inline

Definition at line 52 of file XrdXrootdResponse.hh.

52{return (const char *)trsid;}

Referenced by XrdXrootdCallBack::sendResp(), and XrdXrootdCallBack::sendVesp().

+ Here is the caller graph for this function:

◆ isOurs()

bool XrdXrootdResponse::isOurs ( )
inline

Definition at line 80 of file XrdXrootdResponse.hh.

80{return Bridge == 0;}

◆ operator=()

XrdXrootdResponse & XrdXrootdResponse::operator= ( const XrdXrootdResponse & rhs)
inline

Definition at line 98 of file XrdXrootdResponse.hh.

99 {Set(rhs.Link);
100 Set(rhs.Bridge);
101 Set((unsigned char *)rhs.Resp.streamid);
102 return *this;
103 }

References XrdXrootdResponse(), Set(), and ServerResponseHeader::streamid.

+ Here is the call graph for this function:

◆ Send() [1/14]

int XrdXrootdResponse::Send ( const char * msg)

Definition at line 86 of file XrdXrootdResponse.cc.

87{
88 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
89
90 TRACES(RSP, "sending OK: " <<msg);
91
92 RespIO[1].iov_base = (caddr_t)msg;
93 RespIO[1].iov_len = strlen(msg)+1;
94
95 if (Bridge)
96 {if (Bridge->Send(kXR_ok,&RespIO[1],1,RespIO[1].iov_len) >= 0) return 0;
97 return Link->setEtext("send failure");
98 }
99
100 Resp.status = isOK;
101 Resp.dlen = static_cast<kXR_int32>(htonl(RespIO[1].iov_len));
102
103 if (Link->Send(RespIO, 2, sizeof(Resp) + RespIO[1].iov_len) < 0)
104 return Link->setEtext("send failure");
105 return 0;
106}
@ kXR_ok
Definition XProtocol.hh:899
int kXR_int32
Definition XPtypes.hh:89
unsigned short kXR_unt16
Definition XPtypes.hh:67
#define TRACES(x)

References kXR_ok, and TRACES.

◆ Send() [2/14]

int XrdXrootdResponse::Send ( int fdnum,
long long offset,
int dlen )

Definition at line 266 of file XrdXrootdResponse.cc.

267{
268 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
269 XrdLink::sfVec myVec[2];
270
271 TRACES(RSP, "sendfile " <<dlen <<" data bytes");
272
273 if (Bridge)
274 {if (Bridge->Send(offset, dlen, fdnum) >= 0) return 0;
275 return Link->setEtext("send failure");
276 }
277
278// We are only called should sendfile be enabled for this response
279//
280 Resp.status = isOK;
281 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
282
283// Fill out the sendfile vector
284//
285 myVec[0].buffer = (char *)&Resp;
286 myVec[0].sendsz = sizeof(Resp);
287 myVec[0].fdnum = -1;
288 myVec[1].offset = static_cast<off_t>(offset);
289 myVec[1].sendsz = dlen;
290 myVec[1].fdnum = fdnum;
291
292// Send off the request
293//
294 if (Link->Send(myVec, 2) < 0)
295 return Link->setEtext("sendfile failure");
296 return 0;
297}
int fdnum
File descriptor for data.
int sendsz
Length of data at offset.

References XrdOucSFVec::fdnum, kXR_ok, XrdOucSFVec::sendsz, and TRACES.

◆ Send() [3/14]

int XrdXrootdResponse::Send ( ServerResponseStatus & srs,
int iLen,
struct iovec * IOResp,
int iovcnt,
int iolen = -1 )

Definition at line 365 of file XrdXrootdResponse.cc.

367{
368 int dlen = 0;
369
370// If we need to compute the amount of data we are sending, do so now.
371//
372 if (iolen < 0) for (int i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
373 else dlen = iolen;
374
375// Fill out the status structure
376//
377 int rspLen = srsComplete(srs, iLen, dlen);
378
379// Complete the iovec for the send
380
381 IOResp[0].iov_base = &srs;
382 IOResp[0].iov_len = rspLen;
383
384// Send the data off
385//
386 if (Link->Send(IOResp, iornum, rspLen + dlen) < 0)
387 return Link->setEtext("send failure");
388 return 0;
389}

◆ Send() [4/14]

int XrdXrootdResponse::Send ( ServerResponseStatus & srs,
int iLen,
void * data,
int dlen )

Definition at line 341 of file XrdXrootdResponse.cc.

343{
344 int rc;
345
346// Send off the appropriate response
347//
348 if (!dlen) rc = Link->Send((char *)&srs, srsComplete(srs, iLen));
349 else {struct iovec srsIOV[2];
350 srsIOV[0].iov_base = &srs;
351 srsIOV[0].iov_len = srsComplete(srs, iLen, dlen);
352 srsIOV[1].iov_base = (caddr_t)data;
353 srsIOV[1].iov_len = dlen;
354 rc = Link->Send(srsIOV, 2, srsIOV[0].iov_len + dlen);
355 }
356
357// Finish up
358//
359 if (rc < 0) return Link->setEtext("send failure");
360 return 0;
361}

◆ Send() [5/14]

int XrdXrootdResponse::Send ( ServerResponseStatus & srs,
int iLen = 0 )

Definition at line 329 of file XrdXrootdResponse.cc.

330{
331
332// Fill out the status structure and send this off
333//
334 if (Link->Send((char *)&srs, srsComplete(srs, iLen)) < 0)
335 return Link->setEtext("send failure");
336 return 0;
337}

◆ Send() [6/14]

int XrdXrootdResponse::Send ( struct iovec * IOResp,
int iovcnt,
int iolen = -1 )

Definition at line 211 of file XrdXrootdResponse.cc.

212{
213 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
214 int dlen = 0;
215
216 if (iolen < 0) for (int i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
217 else dlen = iolen;
218 TRACES(RSP, "sending " <<dlen <<" data bytes; status=0");
219
220
221 if (Bridge)
222 {if (Bridge->Send(kXR_ok, &IOResp[1], iornum-1, dlen) >= 0) return 0;
223 return Link->setEtext("send failure");
224 }
225
226 IOResp[0].iov_base = RespIO[0].iov_base;
227 IOResp[0].iov_len = RespIO[0].iov_len;
228 Resp.status = isOK;
229 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
230
231 if (Link->Send(IOResp, iornum, sizeof(Resp) + dlen) < 0)
232 return Link->setEtext("send failure");
233 return 0;
234}

References kXR_ok, and TRACES.

◆ Send() [7/14]

int XrdXrootdResponse::Send ( void * data,
int dlen )

Definition at line 187 of file XrdXrootdResponse.cc.

188{
189 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
190
191 TRACES(RSP, "sending " <<dlen <<" data bytes");
192
193 RespIO[1].iov_base = (caddr_t)data;
194 RespIO[1].iov_len = dlen;
195
196 if (Bridge)
197 {if (Bridge->Send(kXR_ok, &RespIO[1], 1, dlen) >= 0) return 0;
198 return Link->setEtext("send failure");
199 }
200
201 Resp.status = isOK;
202 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
203
204 if (Link->Send(RespIO, 2, sizeof(Resp) + dlen) < 0)
205 return Link->setEtext("send failure");
206 return 0;
207}

References kXR_ok, and TRACES.

◆ Send() [8/14]

int XrdXrootdResponse::Send ( void )

Definition at line 65 of file XrdXrootdResponse.cc.

66{
67 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
68
69 TRACES(RSP, "sending OK");
70
71 if (Bridge)
72 {if (Bridge->Send(kXR_ok, 0, 0, 0) >= 0) return 0;
73 return Link->setEtext("send failure");
74 }
75
76 Resp.status = isOK;
77 Resp.dlen = 0;
78
79 if (Link->Send((char *)&Resp, sizeof(Resp)) < 0)
80 return Link->setEtext("send failure");
81 return 0;
82}

References kXR_ok, and TRACES.

Referenced by XrdXrootdJob::Schedule(), XrdXrootdCallBack::sendResp(), XrdXrootdCallBack::sendVesp(), and XrdXrootdStats::Stats().

+ Here is the caller graph for this function:

◆ Send() [9/14]

int XrdXrootdResponse::Send ( XErrorCode ecode,
const char * msg )

Definition at line 238 of file XrdXrootdResponse.cc.

239{
240 int dlen;
241 kXR_int32 erc = static_cast<kXR_int32>(htonl(ecode));
242
243 TRACES(EMSG, "sending err " <<ecode <<": " <<msg);
244
245 RespIO[1].iov_base = (char *)&erc;
246 RespIO[1].iov_len = sizeof(erc);
247 RespIO[2].iov_base = (caddr_t)msg;
248 RespIO[2].iov_len = strlen(msg)+1;
249 dlen = sizeof(erc) + RespIO[2].iov_len;
250
251 if (Bridge)
252 {if (Bridge->Send(kXR_error, &RespIO[1], 2, dlen) >= 0) return 0;
253 return Link->setEtext("send failure");
254 }
255
256 Resp.status = static_cast<kXR_unt16>(htons(kXR_error));
257 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
258
259 if (Link->Send(RespIO, 3, sizeof(Resp) + dlen) < 0)
260 return Link->setEtext("send failure");
261 return 0;
262}
@ kXR_error
Definition XProtocol.hh:903
#define EMSG(x)

References EMSG, kXR_error, and TRACES.

◆ Send() [10/14]

int XrdXrootdResponse::Send ( XrdOucSFVec * sfvec,
int sfvnum,
int dlen )

Definition at line 301 of file XrdXrootdResponse.cc.

302{
303 static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
304
305 TRACES(RSP, "sendfile " <<dlen <<" data bytes");
306
307 if (Bridge)
308 {if (Bridge->Send(sfvec, sfvnum, dlen) >= 0) return 0;
309 return Link->setEtext("send failure");
310 }
311
312// We are only called should sendfile be enabled for this response
313//
314 Resp.status = isOK;
315 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
316 sfvec[0].buffer = (char *)&Resp;
317 sfvec[0].sendsz = sizeof(Resp);
318 sfvec[0].fdnum = -1;
319
320// Send off the request
321//
322 if (Link->Send(sfvec, sfvnum) < 0)
323 return Link->setEtext("sendfile failure");
324 return 0;
325}

References XrdOucSFVec::fdnum, kXR_ok, XrdOucSFVec::sendsz, and TRACES.

◆ Send() [11/14]

int XrdXrootdResponse::Send ( XrdXrootdReqID & ReqID,
XResponseType Status,
struct iovec * IOResp,
int iornum,
int iolen )
static

Definition at line 393 of file XrdXrootdResponse.cc.

398{
399 static const kXR_unt16 Xattn = static_cast<kXR_unt16>(htons(kXR_attn));
400 static const kXR_int32 Xarsp = static_cast<kXR_int32>(htonl(kXR_asynresp));
401
402// We would have used struct ServerResponseBody_Attn_asynresp but the silly
403// imbedded 4096 char array causes grief when computing lengths.
404//
405 struct {ServerResponseHeader atnHdr;
406 kXR_int32 act;
407 kXR_int32 rsvd; // Same as char[4]
408 ServerResponseHeader theHdr;
409 } asynResp;
410
411 static const int sfxLen = sizeof(asynResp) - sizeof(asynResp.atnHdr);
412
413 XrdLink *Link;
414 unsigned char theSID[2];
415 int theFD, rc, ioxlen = iolen;
416 unsigned int theInst;
417
418// Fill out the header with constant information
419//
420 asynResp.atnHdr.streamid[0] = '\0';
421 asynResp.atnHdr.streamid[1] = '\0';
422 asynResp.atnHdr.status = Xattn;
423 asynResp.act = Xarsp;
424 asynResp.rsvd = 0;
425
426// Complete the io vector to send this response
427//
428 IOResp[0].iov_base = (char *)&asynResp;
429 IOResp[0].iov_len = sizeof(asynResp); // 0
430
431// Insert the status code
432//
433 asynResp.theHdr.status = static_cast<kXR_unt16>(htons(Status));
434
435// We now insert the length of the delayed response and the full response
436//
437 asynResp.theHdr.dlen = static_cast<kXR_int32>(htonl(iolen));
438 iolen += sfxLen;
439 asynResp.atnHdr.dlen = static_cast<kXR_int32>(htonl(iolen));
440 iolen += sizeof(ServerResponseHeader);
441
442// Decode the destination
443//
444 ReqID.getID(theSID, theFD, theInst);
445
446// Map the destination to an endpoint, and send the response
447//
448 if ((Link = XrdLinkCtl::fd2link(theFD, theInst)))
449 {Link->setRef(1);
450 if (Link->isInstance(theInst))
451 {if (Link->hasBridge())
452 rc = XrdXrootdTransit::Attn(Link, (short *)theSID, int(Status),
453 &IOResp[1], iornum-1, ioxlen);
454 else {asynResp.theHdr.streamid[0] = theSID[0];
455 asynResp.theHdr.streamid[1] = theSID[1];
456 rc = Link->Send(IOResp, iornum, iolen);
457 }
458 } else rc = -1;
459 Link->setRef(-1);
460 return (rc < 0 ? -1 : 0);
461 }
462 return -1;
463}
@ kXR_asynresp
Definition XProtocol.hh:938
@ kXR_attn
Definition XProtocol.hh:901
static XrdLink * fd2link(int fd)
Definition XrdLinkCtl.hh:72
unsigned long long getID()
static int Attn(XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle attention response (i.e. async response)

References XrdXrootdTransit::Attn(), XrdLinkCtl::fd2link(), XrdXrootdReqID::getID(), kXR_asynresp, and kXR_attn.

+ Here is the call graph for this function:

◆ Send() [12/14]

int XrdXrootdResponse::Send ( XResponseType rcode,
int info,
const char * data,
int dsz = -1 )

Definition at line 159 of file XrdXrootdResponse.cc.

161{
162 kXR_int32 xbuf = static_cast<kXR_int32>(htonl(info));
163 int dlen;
164
165 RespIO[1].iov_base = (caddr_t)(&xbuf);
166 RespIO[1].iov_len = sizeof(xbuf);
167 RespIO[2].iov_base = (caddr_t)data;
168 RespIO[2].iov_len = dlen = (dsz < 0 ? strlen(data) : dsz);
169
170 TRACES(RSP,"sending " <<(sizeof(xbuf)+dlen) <<" data bytes; status=" <<rcode);
171
172 if (Bridge)
173 {if (Bridge->Send(rcode, &RespIO[1], 2, dlen) >= 0) return 0;
174 return Link->setEtext("send failure");
175 }
176
177 Resp.status = static_cast<kXR_unt16>(htons(rcode));
178 Resp.dlen = static_cast<kXR_int32>(htonl((dlen+sizeof(xbuf))));
179
180 if (Link->Send(RespIO, 3, sizeof(Resp) + dlen + sizeof(xbuf)) < 0)
181 return Link->setEtext("send failure");
182 return 0;
183}

References TRACES.

◆ Send() [13/14]

int XrdXrootdResponse::Send ( XResponseType rcode,
struct iovec * IOResp,
int iornum,
int iolen = -1 )

Definition at line 133 of file XrdXrootdResponse.cc.

135{
136 int i, dlen = 0;
137
138 if (iolen < 0) for (i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
139 else dlen = iolen;
140 TRACES(RSP, "sending " <<dlen <<" data bytes; status=" <<rcode);
141
142 if (Bridge)
143 {if (Bridge->Send(rcode, &IOResp[1], iornum-1, dlen) >= 0) return 0;
144 return Link->setEtext("send failure");
145 }
146
147 IOResp[0].iov_base = RespIO[0].iov_base;
148 IOResp[0].iov_len = RespIO[0].iov_len;
149 Resp.status = static_cast<kXR_unt16>(htons(rcode));
150 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
151
152 if (Link->Send(IOResp, iornum, sizeof(Resp) + dlen) < 0)
153 return Link->setEtext("send failure");
154 return 0;
155}

References TRACES.

◆ Send() [14/14]

int XrdXrootdResponse::Send ( XResponseType rcode,
void * data,
int dlen )

Definition at line 110 of file XrdXrootdResponse.cc.

111{
112
113 TRACES(RSP, "sending " <<dlen <<" data bytes; status=" <<rcode);
114
115 RespIO[1].iov_base = (caddr_t)data;
116 RespIO[1].iov_len = dlen;
117
118 if (Bridge)
119 {if (Bridge->Send(rcode, &RespIO[1], 1, dlen) >= 0) return 0;
120 return Link->setEtext("send failure");
121 }
122
123 Resp.status = static_cast<kXR_unt16>(htons(rcode));
124 Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
125
126 if (Link->Send(RespIO, 2, sizeof(Resp) + dlen) < 0)
127 return Link->setEtext("send failure");
128 return 0;
129}

References TRACES.

◆ Set() [1/3]

void XrdXrootdResponse::Set ( kXR_char * stream)

Definition at line 469 of file XrdXrootdResponse.cc.

470{
471 static char hv[] = "0123456789abcdef";
472 char *outbuff;
473 int i;
474
475 Resp.streamid[0] = stream[0];
476 Resp.streamid[1] = stream[1];
477
479 {outbuff = trsid;
480 for (i = 0; i < (int)sizeof(Resp.streamid); i++)
481 {*outbuff++ = hv[(stream[i] >> 4) & 0x0f];
482 *outbuff++ = hv[ stream[i] & 0x0f];
483 }
484 *outbuff++ = ' '; *outbuff = '\0';
485 }
486}
#define TRACE_REQ
#define TRACE_RSP
#define TRACING(x)
Definition XrdTrace.hh:70

References TRACE_REQ, TRACE_RSP, and TRACING.

◆ Set() [2/3]

void XrdXrootdResponse::Set ( XrdLink * lp)
inline

Definition at line 76 of file XrdXrootdResponse.hh.

76{Link = lp;}

Referenced by XrdXrootdResponse(), XrdXrootdProtocol::Match(), operator=(), XrdXrootdCallBack::sendResp(), and XrdXrootdCallBack::sendVesp().

+ Here is the caller graph for this function:

◆ Set() [3/3]

void XrdXrootdResponse::Set ( XrdXrootdTransit * tp)
inline

Definition at line 77 of file XrdXrootdResponse.hh.

77{Bridge = tp;}

◆ StreamID()

void XrdXrootdResponse::StreamID ( kXR_char * sid)
inline

Definition at line 83 of file XrdXrootdResponse.hh.

83 {sid[0] = Resp.streamid[0];
84 sid[1] = Resp.streamid[1];
85 }

◆ theLink()

XrdLink * XrdXrootdResponse::theLink ( )
inline

Definition at line 82 of file XrdXrootdResponse.hh.

82{return Link;}

Referenced by XrdXrootdAioTask::Init().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: