XRootD
XrdXrootdTransSend Class Reference

#include <XrdXrootdTransSend.hh>

+ Inheritance diagram for XrdXrootdTransSend:
+ Collaboration diagram for XrdXrootdTransSend:

Public Member Functions

 XrdXrootdTransSend (XrdLink *lP, kXR_char *sid, kXR_unt16 req, long long offset, int dlen, int fdnum)
 
 XrdXrootdTransSend (XrdLink *lP, kXR_char *sid, kXR_unt16 req, XrdOucSFVec *sfvec, int sfvnum, int dlen)
 
 ~XrdXrootdTransSend ()
 
int Send (const struct iovec *headP, int headN, const struct iovec *tailP, int tailN)
 
- Public Member Functions inherited from XrdXrootd::Bridge::Context
 Context (XrdLink *lP, kXR_char *sid, kXR_unt16 req)
 Constructor and Destructor. More...
 
virtual ~Context ()
 

Additional Inherited Members

- Public Attributes inherited from XrdXrootd::Bridge::Context
XrdLinklinkP
 -> associated session link object (i.e. connection) More...
 
kXR_unt16 rCode
 associated "kXR" request code in host byte order More...
 
union {
kXR_char chr [2]
 associated stream ID as the original char[2] More...
 
kXR_unt16 num
 associated stream ID as a short More...
 
sID
 associated request stream ID More...
 

Detailed Description

Definition at line 40 of file XrdXrootdTransSend.hh.

Constructor & Destructor Documentation

◆ XrdXrootdTransSend() [1/2]

XrdXrootdTransSend::XrdXrootdTransSend ( XrdLink lP,
kXR_char sid,
kXR_unt16  req,
long long  offset,
int  dlen,
int  fdnum 
)
inline

Definition at line 52 of file XrdXrootdTransSend.hh.

54  : Context(lP, sid, req),
55  sfOff(offset), sfLen(dlen), sfFD(fdnum) {}
Context(XrdLink *lP, kXR_char *sid, kXR_unt16 req)
Constructor and Destructor.

◆ XrdXrootdTransSend() [2/2]

XrdXrootdTransSend::XrdXrootdTransSend ( XrdLink lP,
kXR_char sid,
kXR_unt16  req,
XrdOucSFVec sfvec,
int  sfvnum,
int  dlen 
)
inline

Definition at line 57 of file XrdXrootdTransSend.hh.

59  : Context(lP, sid, req),
60  sfVP(sfvec), sfLen(dlen), sfFD(-sfvnum) {}

◆ ~XrdXrootdTransSend()

XrdXrootdTransSend::~XrdXrootdTransSend ( )
inline

Definition at line 62 of file XrdXrootdTransSend.hh.

62 {}

Member Function Documentation

◆ Send()

int XrdXrootdTransSend::Send ( const struct iovec *  headP,
int  headN,
const struct iovec *  tailP,
int  tailN 
)
virtual

Complete a File() callback.

The Send() method must be called after the File() callback is invoked to complete data transmission using sendfile(). If Send() is not called the pending sendfile() call is not made and no data is sent to the client.

Parameters
headPa pointer to the iovec structure containing the data that must be sent before the sendfile() data. If there is none, the pointer can be null.
headNthe number of elements in the headP iovec structure array.
tailPa pointer to the iovec structure containing the data that must be sent after the sendfile() data. If there is none, the pointer can be null.
tailNthe number of elements in the tailP iovec structure array.
Returns
< 0 transmission error has occurred. This can be due to either connection failure or data source error (i.e. I/O error). = 0 data has been successfully sent. > 0 the supplied context was not generated by a valid File() callback. No data has been sent.
Parameters
headPpointer to leading data array
headNarray count
tailPpointer to trailing data array
tailNarray count

Reimplemented from XrdXrootd::Bridge::Context.

Definition at line 38 of file XrdXrootdTransSend.cc.

40 {
41  XrdLink::sfVec *sfVec;
42  int i, k = 0, numV = headN + tailN + 1;
43 
44 // Allocate a new sfVec to accomodate all the items
45 //
46  if (sfFD >= 0) sfVec = new XrdLink::sfVec[numV];
47  else sfVec = new XrdLink::sfVec[numV-sfFD];
48 
49 // Copy the headers
50 //
51  if (headP) for (i = 0; i < headN; i++, k++)
52  {sfVec[k].buffer = (char *)headP[i].iov_base;
53  sfVec[k].sendsz = headP[i].iov_len;
54  sfVec[k].fdnum = -1;
55  }
56 
57 // Insert the sendfile request
58 //
59  if (sfFD >= 0)
60  {sfVec[k].offset = sfOff;
61  sfVec[k].sendsz = sfLen;
62  sfVec[k].fdnum = sfFD;
63  k++;
64  } else {
65  for (i = 1; i < -sfFD; i++)
66  {sfVec[k ].offset = sfVP[i].offset;
67  sfVec[k ].sendsz = sfVP[i].sendsz;
68  sfVec[k++].fdnum = sfVP[i].fdnum;
69  }
70  }
71 
72 // Copy the trailer
73 //
74  if (tailP) for (i = 0; i < tailN; i++, k++)
75  {sfVec[k].buffer = (char *)tailP[i].iov_base;
76  sfVec[k].sendsz = tailP[i].iov_len;
77  sfVec[k].fdnum = -1;
78  }
79 
80 // Issue sendfile request
81 //
82  k = linkP->Send(sfVec, numV);
83 
84 // Deallocate the vector and return the result
85 //
86  delete [] sfVec;
87  return (k < 0 ? -1 : 0);
88 }
XrdLink * linkP
-> associated session link object (i.e. connection)
int fdnum
File descriptor for data.
Definition: XrdOucSFVec.hh:47
int sendsz
Length of data at offset.
Definition: XrdOucSFVec.hh:46

References XrdOucSFVec::fdnum, XrdXrootd::Bridge::Context::linkP, XrdLink::Send(), and XrdOucSFVec::sendsz.

+ Here is the call graph for this function:

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