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 ()
XrdXrootdResponse & | operator= (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)
XrdLink * | theLink ()

## 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.

{Set(rhs.Link);
Set(rhs.Bridge);
Set(rhs.Resp.streamid);
}
ServerResponseHeader::streamid
kXR_char streamid[2]
Definition XProtocol.hh:914
XrdXrootdResponse::Set
void Set(XrdLink *lp)
Definition XrdXrootdResponse.hh:76

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.

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

## ~XrdXrootdResponse()

XrdXrootdResponse::~XrdXrootdResponse | ( |  | ) |

inline

Definition at line 96 of file XrdXrootdResponse.hh.

{}

## Member Function Documentation

## ID()

const char * XrdXrootdResponse::ID | ( |  | ) |

inline

Definition at line 52 of file XrdXrootdResponse.hh.

{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.

{return Bridge == 0;}

## operator=()

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

inline

Definition at line 98 of file XrdXrootdResponse.hh.

{Set(rhs.Link);
Set(rhs.Bridge);
Set((unsigned char *)rhs.Resp.streamid);
return *this;
}

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.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
TRACES(RSP, "sending OK: " <<msg);
RespIO[1].iov_base = (caddr_t)msg;
RespIO[1].iov_len = strlen(msg)+1;
if (Bridge)
{if (Bridge->Send(kXR_ok,&RespIO[1],1,RespIO[1].iov_len) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = isOK;
Resp.dlen = static_cast<kXR_int32>(htonl(RespIO[1].iov_len));
if (Link->Send(RespIO, 2, sizeof(Resp) + RespIO[1].iov_len) < 0)
return Link->setEtext("send failure");
return 0;
}
kXR_ok
@ kXR_ok
Definition XProtocol.hh:899
kXR_int32
int kXR_int32
Definition XPtypes.hh:89
kXR_unt16
unsigned short kXR_unt16
Definition XPtypes.hh:67
TRACES
#define TRACES(x)
Definition XrdBwmTrace.hh:42

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.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
XrdLink::sfVec myVec[2];
TRACES(RSP, "sendfile " <<dlen <<" data bytes");
if (Bridge)
{if (Bridge->Send(offset, dlen, fdnum) >= 0) return 0;
return Link->setEtext("send failure");
}
// We are only called should sendfile be enabled for this response
//
Resp.status = isOK;
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
// Fill out the sendfile vector
//
myVec[0].buffer = (char *)&Resp;
myVec[0].sendsz = sizeof(Resp);
myVec[0].fdnum = -1;
myVec[1].offset = static_cast<off_t>(offset);
myVec[1].sendsz = dlen;
myVec[1].fdnum = fdnum;
// Send off the request
//
if (Link->Send(myVec, 2) < 0)
return Link->setEtext("sendfile failure");
return 0;
}
XrdLink::sfVec
XrdOucSFVec sfVec
Definition XrdLink.hh:390
XrdOucSFVec::fdnum
int fdnum
File descriptor for data.
Definition XrdOucSFVec.hh:47
XrdOucSFVec::sendsz
int sendsz
Length of data at offset.
Definition XrdOucSFVec.hh:46

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.

{
int dlen = 0;
// If we need to compute the amount of data we are sending, do so now.
//
if (iolen < 0) for (int i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
else dlen = iolen;
// Fill out the status structure
//
int rspLen = srsComplete(srs, iLen, dlen);
// Complete the iovec for the send
IOResp[0].iov_base = &srs;
IOResp[0].iov_len = rspLen;
// Send the data off
//
if (Link->Send(IOResp, iornum, rspLen + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}

## Send() [4/14]

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

Definition at line 341 of file XrdXrootdResponse.cc.

{
int rc;
// Send off the appropriate response
//
if (!dlen) rc = Link->Send((char *)&srs, srsComplete(srs, iLen));
else {struct iovec srsIOV[2];
srsIOV[0].iov_base = &srs;
srsIOV[0].iov_len = srsComplete(srs, iLen, dlen);
srsIOV[1].iov_base = (caddr_t)data;
srsIOV[1].iov_len = dlen;
rc = Link->Send(srsIOV, 2, srsIOV[0].iov_len + dlen);
}
// Finish up
//
if (rc < 0) return Link->setEtext("send failure");
return 0;
}

## Send() [5/14]

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

Definition at line 329 of file XrdXrootdResponse.cc.

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

## Send() [6/14]

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

Definition at line 211 of file XrdXrootdResponse.cc.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
int dlen = 0;
if (iolen < 0) for (int i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
else dlen = iolen;
TRACES(RSP, "sending " <<dlen <<" data bytes; status=0");
if (Bridge)
{if (Bridge->Send(kXR_ok, &IOResp[1], iornum-1, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
IOResp[0].iov_base = RespIO[0].iov_base;
IOResp[0].iov_len = RespIO[0].iov_len;
Resp.status = isOK;
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
if (Link->Send(IOResp, iornum, sizeof(Resp) + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}

References kXR_ok, and TRACES.

## Send() [7/14]

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

Definition at line 187 of file XrdXrootdResponse.cc.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
TRACES(RSP, "sending " <<dlen <<" data bytes");
RespIO[1].iov_base = (caddr_t)data;
RespIO[1].iov_len = dlen;
if (Bridge)
{if (Bridge->Send(kXR_ok, &RespIO[1], 1, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = isOK;
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
if (Link->Send(RespIO, 2, sizeof(Resp) + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}

References kXR_ok, and TRACES.

## Send() [8/14]

int XrdXrootdResponse::Send | ( | void |  | ) |

Definition at line 65 of file XrdXrootdResponse.cc.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
TRACES(RSP, "sending OK");
if (Bridge)
{if (Bridge->Send(kXR_ok, 0, 0, 0) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = isOK;
Resp.dlen = 0;
if (Link->Send((char *)&Resp, sizeof(Resp)) < 0)
return Link->setEtext("send failure");
return 0;
}

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.

{
int dlen;
kXR_int32 erc = static_cast<kXR_int32>(htonl(ecode));
TRACES(EMSG, "sending err " <<ecode <<": " <<msg);
RespIO[1].iov_base = (char *)&erc;
RespIO[1].iov_len = sizeof(erc);
RespIO[2].iov_base = (caddr_t)msg;
RespIO[2].iov_len = strlen(msg)+1;
dlen = sizeof(erc) + RespIO[2].iov_len;
if (Bridge)
{if (Bridge->Send(kXR_error, &RespIO[1], 2, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = static_cast<kXR_unt16>(htons(kXR_error));
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
if (Link->Send(RespIO, 3, sizeof(Resp) + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}
kXR_error
@ kXR_error
Definition XProtocol.hh:903
EMSG
#define EMSG(x)
Definition XrdCpConfig.cc:55

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.

{
static kXR_unt16 isOK = static_cast<kXR_unt16>(htons(kXR_ok));
TRACES(RSP, "sendfile " <<dlen <<" data bytes");
if (Bridge)
{if (Bridge->Send(sfvec, sfvnum, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
// We are only called should sendfile be enabled for this response
//
Resp.status = isOK;
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
sfvec[0].buffer = (char *)&Resp;
sfvec[0].sendsz = sizeof(Resp);
sfvec[0].fdnum = -1;
// Send off the request
//
if (Link->Send(sfvec, sfvnum) < 0)
return Link->setEtext("sendfile failure");
return 0;
}

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.

{
static const kXR_unt16 Xattn = static_cast<kXR_unt16>(htons(kXR_attn));
static const kXR_int32 Xarsp = static_cast<kXR_int32>(htonl(kXR_asynresp));
// We would have used struct ServerResponseBody_Attn_asynresp but the silly
// imbedded 4096 char array causes grief when computing lengths.
//
struct {ServerResponseHeader atnHdr;
kXR_int32 act;
kXR_int32 rsvd; // Same as char[4]
ServerResponseHeader theHdr;
} asynResp;
static const int sfxLen = sizeof(asynResp) - sizeof(asynResp.atnHdr);
XrdLink *Link;
unsigned char theSID[2];
int theFD, rc, ioxlen = iolen;
unsigned int theInst;
// Fill out the header with constant information
//
asynResp.atnHdr.streamid[0] = '\0';
asynResp.atnHdr.streamid[1] = '\0';
asynResp.atnHdr.status = Xattn;
asynResp.act = Xarsp;
asynResp.rsvd = 0;
// Complete the io vector to send this response
//
IOResp[0].iov_base = (char *)&asynResp;
IOResp[0].iov_len = sizeof(asynResp); // 0
// Insert the status code
//
asynResp.theHdr.status = static_cast<kXR_unt16>(htons(Status));
// We now insert the length of the delayed response and the full response
//
asynResp.theHdr.dlen = static_cast<kXR_int32>(htonl(iolen));
iolen += sfxLen;
asynResp.atnHdr.dlen = static_cast<kXR_int32>(htonl(iolen));
iolen += sizeof(ServerResponseHeader);
// Decode the destination
//
ReqID.getID(theSID, theFD, theInst);
// Map the destination to an endpoint, and send the response
//
if ((Link = XrdLinkCtl::fd2link(theFD, theInst)))
{Link->setRef(1);
if (Link->isInstance(theInst))
{if (Link->hasBridge())
rc = XrdXrootdTransit::Attn(Link, (short *)theSID, int(Status),
&IOResp[1], iornum-1, ioxlen);
else {asynResp.theHdr.streamid[0] = theSID[0];
asynResp.theHdr.streamid[1] = theSID[1];
rc = Link->Send(IOResp, iornum, iolen);
}
} else rc = -1;
Link->setRef(-1);
return (rc < 0 ? -1 : 0);
}
return -1;
}
kXR_asynresp
@ kXR_asynresp
Definition XProtocol.hh:938
kXR_attn
@ kXR_attn
Definition XProtocol.hh:901
XrdLinkCtl::fd2link
static XrdLink * fd2link(int fd)
Definition XrdLinkCtl.hh:72
XrdXrootdReqID::getID
unsigned long long getID()
Definition XrdXrootdReqID.hh:39
XrdXrootdTransit::Attn
static int Attn(XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle attention response (i.e. async response).
Definition XrdXrootdTransit.cc:97

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.

{
kXR_int32 xbuf = static_cast<kXR_int32>(htonl(info));
int dlen;
RespIO[1].iov_base = (caddr_t)(&xbuf);
RespIO[1].iov_len = sizeof(xbuf);
RespIO[2].iov_base = (caddr_t)data;
RespIO[2].iov_len = dlen = (dsz < 0 ? strlen(data) : dsz);
TRACES(RSP,"sending " <<(sizeof(xbuf)+dlen) <<" data bytes; status=" <<rcode);
if (Bridge)
{if (Bridge->Send(rcode, &RespIO[1], 2, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = static_cast<kXR_unt16>(htons(rcode));
Resp.dlen = static_cast<kXR_int32>(htonl((dlen+sizeof(xbuf))));
if (Link->Send(RespIO, 3, sizeof(Resp) + dlen + sizeof(xbuf)) < 0)
return Link->setEtext("send failure");
return 0;
}

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.

{
int i, dlen = 0;
if (iolen < 0) for (i = 1; i < iornum; i++) dlen += IOResp[i].iov_len;
else dlen = iolen;
TRACES(RSP, "sending " <<dlen <<" data bytes; status=" <<rcode);
if (Bridge)
{if (Bridge->Send(rcode, &IOResp[1], iornum-1, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
IOResp[0].iov_base = RespIO[0].iov_base;
IOResp[0].iov_len = RespIO[0].iov_len;
Resp.status = static_cast<kXR_unt16>(htons(rcode));
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
if (Link->Send(IOResp, iornum, sizeof(Resp) + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}

References TRACES.

## Send() [14/14]

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

Definition at line 110 of file XrdXrootdResponse.cc.

{
TRACES(RSP, "sending " <<dlen <<" data bytes; status=" <<rcode);
RespIO[1].iov_base = (caddr_t)data;
RespIO[1].iov_len = dlen;
if (Bridge)
{if (Bridge->Send(rcode, &RespIO[1], 1, dlen) >= 0) return 0;
return Link->setEtext("send failure");
}
Resp.status = static_cast<kXR_unt16>(htons(rcode));
Resp.dlen = static_cast<kXR_int32>(htonl(dlen));
if (Link->Send(RespIO, 2, sizeof(Resp) + dlen) < 0)
return Link->setEtext("send failure");
return 0;
}

References TRACES.

## Set() [1/3]

void XrdXrootdResponse::Set | ( | kXR_char * | stream | ) |

Definition at line 469 of file XrdXrootdResponse.cc.

{
static const char hv[] = "0123456789abcdef";
char *outbuff;
int i;
Resp.streamid[0] = stream[0];
Resp.streamid[1] = stream[1];
if (TRACING((TRACE_REQ|TRACE_RSP)))
{outbuff = trsid;
for (i = 0; i < (int)sizeof(Resp.streamid); i++)
{*outbuff++ = hv[(stream[i] >> 4) & 0x0f];
*outbuff++ = hv[ stream[i] & 0x0f];
}
*outbuff++ = ' '; *outbuff = '\0';
}
}
TRACE_REQ
#define TRACE_REQ
Definition XrdHttpTrace.hh:51
TRACE_RSP
#define TRACE_RSP
Definition XrdHttpTrace.hh:53
TRACING
#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.

{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.

{Bridge = tp;}

## StreamID()

void XrdXrootdResponse::StreamID | ( | kXR_char * | sid | ) |

inline

Definition at line 83 of file XrdXrootdResponse.hh.

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

## theLink()

XrdLink * XrdXrootdResponse::theLink | ( |  | ) |

inline

Definition at line 82 of file XrdXrootdResponse.hh.

{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:

- XrdXrootdResponse.hh
- XrdXrootdResponse.cc