XRootD
XrdXrootdTransit Class Reference

#include <XrdXrootdTransit.hh>

+ Inheritance diagram for XrdXrootdTransit:
+ Collaboration diagram for XrdXrootdTransit:

Public Member Functions

 XrdXrootdTransit ()
 Constructor & Destructor. More...
 
virtual ~XrdXrootdTransit ()
 
bool Disc ()
 Handle dismantlement. More...
 
void Proceed ()
 Resume processing after a waitresp completion. More...
 
int Process (XrdLink *lp)
 Handle link activation (replaces parent activation). More...
 
void Recycle (XrdLink *lp, int consec, const char *reason)
 Handle link shutdown. More...
 
void Redrive ()
 Redrive a request after a wait. More...
 
bool Run (const char *xreqP, char *xdataP=0, int xdataL=0)
 Inject an xrootd request into the protocol stack. More...
 
int Send (int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
 Handle request data response. More...
 
int Send (long long offset, int dlen, int fdnum)
 Handle request sendfile response. More...
 
int Send (XrdOucSFVec *sfvec, int sfvnum, int dlen)
 
int setSF (kXR_char *fhandle, bool seton=false)
 Set sendfile() enablement. More...
 
void SetWait (int wtime, bool notify=false)
 Set maximum wait time. More...
 
- Public Member Functions inherited from XrdXrootd::Bridge
 Bridge ()
 Constructor & Destructor. More...
 
- Public Member Functions inherited from XrdXrootdProtocol
 XrdXrootdProtocol ()
 
 ~XrdXrootdProtocol ()
 
void aioUpdate (int val)
 
void aioUpdReq (int val)
 
XrdSfsXioHandle Claim (const char *buff, int datasz, int minasz=0) override
 
int do_WriteSpan ()
 
void DoIt () override
 
int getData (gdCallBack *gdcbP, const char *dtype, char *buff, int blen)
 
int getData (gdCallBack *gdcbP, const char *dtype, struct iovec *iov, int iovn)
 
int getDump (const char *dtype, int dlen)
 
int getPathID ()
 
XrdProtocolMatch (XrdLink *lp) override
 
XrdXrootdProtocol operator= (const XrdXrootdProtocol &rhs)=delete
 
int Process2 ()
 
int ProcSig ()
 
int SendFile (int fildes) override
 
int SendFile (XrdOucSFVec *sfvec, int sfvnum) override
 
void SetFD (int fildes) override
 
int Stats (char *buff, int blen, int do_sync=0) override
 
void StreamNOP ()
 
XrdSfsXioHandle Swap (const char *buff, XrdSfsXioHandle h=0) override
 
XrdXrootdProtocolVerifyStream (int &rc, int pID, bool lok=true)
 
- Public Member Functions inherited from XrdProtocol
 XrdProtocol (const char *jname)
 
virtual ~XrdProtocol ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 
- Public Member Functions inherited from XrdXrootd::gdCallBack
 gdCallBack ()
 
virtual ~gdCallBack ()
 
virtual void gdFail ()
 
- Public Member Functions inherited from XrdSfsDio
 XrdSfsDio ()
 Constructor and destructor. More...
 
virtual ~XrdSfsDio ()
 
- Public Member Functions inherited from XrdSfsXio
 XrdSfsXio (XrdSfsXioImpl &xioimpl)
 
virtual ~XrdSfsXio ()
 Constructor and destructor. More...
 

Static Public Member Functions

static XrdXrootdTransitAlloc (XrdXrootd::Bridge::Result *respP, XrdLink *linkP, XrdSecEntity *seceP, const char *nameP, const char *protP)
 Get a new transit object. More...
 
static int Attn (XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
 Handle attention response (i.e. async response) More...
 
static void Init (XrdScheduler *schedP, int qMax, int qTTL)
 Perform one-time initialization. More...
 
static const char * ReqTable ()
 Initialize the valid request table. More...
 
- Static Public Member Functions inherited from XrdXrootd::Bridge
static BridgeLogin (Result *rsltP, XrdLink *linkP, XrdSecEntity *seceP, const char *nameP, const char *protP)
 
- Static Public Member Functions inherited from XrdXrootdProtocol
static char * Buffer (XrdSfsXioHandle h, int *bsz)
 
static int Configure (char *parms, XrdProtocol_Config *pi)
 
static void Reclaim (XrdSfsXioHandle h)
 
- Static Public Member Functions inherited from XrdSfsXio
static char * Buffer (XrdSfsXioHandle theHand, int *buffsz=0)
 
static void Reclaim (XrdSfsXioHandle theHand)
 

Additional Inherited Members

- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 
- Static Public Attributes inherited from XrdXrootdProtocol
static bool as_aioOK = true
 
static bool as_force = false
 
static int as_maxperlnk = 8
 
static int as_maxperreq = 8
 
static int as_maxpersrv = 4096
 
static int as_maxstalls = 4
 
static int as_miniosz = 98304
 
static int as_minsfsz = 8192
 
static bool as_nosf = false
 
static short as_okstutter = 1
 
static int as_seghalf = 32768
 
static int as_segsize = 65536
 
static bool as_syncw = false
 
static short as_timeout = 45
 
static const int maxStreams = 16
 
- Protected Member Functions inherited from XrdXrootd::Bridge
virtual ~Bridge ()
 
- Protected Member Functions inherited from XrdXrootdProtocol
void MonAuth ()
 
int SetSF (kXR_char *fhandle, bool seton=false)
 
- Static Protected Member Functions inherited from XrdXrootdProtocol
static unsigned int getSID ()
 
- Protected Attributes inherited from XrdXrootdProtocol
bool ableTLS
 
char * AppName
 
XrdBufferargp
 
XrdSecProtocolAuthProt
 
unsigned char CapVer
 
XrdSecEntityClient
 
int clientPV
 
int clientRN
 
int cumReadP
 
int cumReads
 
int cumReadV
 
int cumSegsV
 
int cumSegsW
 
int cumWrites
 
int cumWritV
 
char doTLS
 
XrdSysCondVar2endNote
 
XrdSecEntity Entity
 
XrdXrootdFileTableFTab
 
struct XrdXrootdProtocol::GetDataCtl gdCtl
 
int halfBSize
 
int hcNext
 
int hcNow
 
int hcPrev
 
XrdXrootd::IOParms IO
 
bool isActive
 
bool isDead
 
bool isLinkWT
 
bool isNOP
 
bool isTLS
 
XrdLinkLink
 
RAtomic_int linkAioReq
 
XrdXrootdMonitor::User Monitor
 
int myBlast
 
int myBlen
 
char * myBuff
 
unsigned int mySID
 
int myStalls
 
bool newPio
 
int numFiles
 
int numReadP
 
int numReads
 
int numReadV
 
int numSegsV
 
int numSegsW
 
int numWrites
 
int numWritV
 
short PathID
 
XrdXrootdPgwCtlpgwCtl
 
XrdXrootdPiopioFirst
 
XrdXrootdPiopioFree
 
XrdXrootdPiopioLast
 
bool pmDone
 
XrdNetPMark::HandlepmHandle
 
int PrepareCount
 
XrdSecProtectProtect
 
short rdType
 
XrdXrootdReqID ReqID
 
ClientRequest Request
 
char reserved [3]
 
XrdXrootdResponse Response
 
int(XrdXrootdProtocol::* Resume )()
 
int(XrdXrootdProtocol::* ResumePio )()
 
XrdSysSemaphorereTry
 
unsigned char rvSeq
 
char sigBuff [64]
 
bool sigHere
 
bool sigNeed
 
bool sigRead
 
SecurityRequest sigReq
 
ClientRequest sigReq2Ver
 
bool sigWarn
 
char Status
 
XrdXrootdProtocolStream [maxStreams]
 
XrdSysMutex streamMutex
 
long long totReadP
 
XrdSysMutex unbindMutex
 
XrdXrootdWVInfowvInfo
 
unsigned char wvSeq
 
- Static Protected Attributes inherited from XrdXrootdProtocol
static XrdNetSocketAdminSock = 0
 
static XrdBuffManagerBPool
 
static XrdSecServiceCIA = 0
 
static bool CL_Redir = false
 
static XrdSecProtectorDHS = 0
 
static XrdSfsFileSystemdigFS = 0
 
static XrdSysErroreDest = XrdXrootd::eLog
 
static uint64_t fsFeatures = 0
 
static int hailWait
 
static int hcMax = 28657
 
static bool isProxy = false
 
static char isRedir = 0
 
static char JobCKCGI =0
 
static XrdXrootdJobJobCKS = 0
 
static char * JobCKT = 0
 
static XrdOucTListJobCKTLST = 0
 
static char JobLCL = 0
 
static time_t keepT = 86400
 
static bool LimitError = true
 
static XrdXrootdFileLockLocker
 
static int maxBuffsz
 
static const int maxPio = 4
 
static int maxReadv_ior
 
static int maxTransz = 262144
 
static const char * myCName = 0
 
static int myCNlen = 0
 
static gid_t myGID = 0
 
static const char * myGName = "?"
 
static int myGNLen = 1
 
static const char * myInst = 0
 
static int myPID = static_cast<int>(getpid())
 
static int myRole = 0
 
static int myRolf = 0
 
static uid_t myUID = 0
 
static const char * myUName = "?"
 
static int myUNLen = 1
 
static char * Notify = 0
 
static bool OD_Bypass = false
 
static bool OD_Redir = false
 
static int OD_Stall = 33
 
static XrdSfsFileSystemosFS
 
static XrdNetPMarkPMark = 0
 
static int Port
 
static bool PrepareAlt = false
 
static int PrepareLimit = -1
 
static XrdOucReqIDPrepID = 0
 
static int readWait
 
static const char Req_TLSData = 0x01
 
static const char Req_TLSGPFile = 0x02
 
static const char Req_TLSLogin = 0x04
 
static const char Req_TLSSess = 0x08
 
static const char Req_TLSTPC = 0x10
 
static struct XrdXrootdProtocol::RD_Table Route [RD_Num]
 
static struct XrdXrootdProtocol::RC_Table RouteClient
 
static XrdXrootdXPath RPList
 
static XrdXrootdXPath RQList
 
static int RQLxist = 0
 
static XrdSchedulerSched
 
static XrdXrootdStatsSI
 
static RAtomic_int srvrAioOps = {0}
 
static char tlsCap = 0
 
static XrdTlsContexttlsCtx = 0
 
static char tlsNot = 0
 
static int tlsPort = 0
 
static const char * TraceID = "Protocol"
 
static int usxMaxNsz = kXR_faMaxNlen
 
static int usxMaxVsz = kXR_faMaxVlen
 
static char * usxParms = 0
 
static int Window
 
static XrdXrootdXPath XPList
 

Detailed Description

Definition at line 55 of file XrdXrootdTransit.hh.

Constructor & Destructor Documentation

◆ XrdXrootdTransit()

XrdXrootdTransit::XrdXrootdTransit ( )
inline

Constructor & Destructor.

Definition at line 162 of file XrdXrootdTransit.hh.

162  : TranLink(this),
163  respJob(this, &XrdXrootdTransit::Proceed,
164  "Transit proceed"),
165  waitJob(this, &XrdXrootdTransit::Redrive,
166  "Transit redrive")
167  {}
void Redrive()
Redrive a request after a wait.
void Proceed()
Resume processing after a waitresp completion.

Referenced by Alloc().

+ Here is the caller graph for this function:

◆ ~XrdXrootdTransit()

virtual XrdXrootdTransit::~XrdXrootdTransit ( )
inlinevirtual

Definition at line 168 of file XrdXrootdTransit.hh.

168 {}

Member Function Documentation

◆ Alloc()

XrdXrootdTransit * XrdXrootdTransit::Alloc ( XrdXrootd::Bridge::Result respP,
XrdLink linkP,
XrdSecEntity seceP,
const char *  nameP,
const char *  protP 
)
static

Get a new transit object.

Definition at line 77 of file XrdXrootdTransit.cc.

83 {
84  XrdXrootdTransit *xp;
85 
86 // Simply return a new transit object masquerading as a bridge
87 //
88  if (!(xp = TranStack.Pop())) xp = new XrdXrootdTransit();
89  xp->Init(rsltP, linkP, seceP, nameP, protP);
90  return xp;
91 }
T * Pop()
Definition: XrdObject.hh:93
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
XrdXrootdTransit()
Constructor & Destructor.

References XrdXrootdTransit(), Init(), and XrdObjectQ< T >::Pop().

Referenced by XrdXrootd::Bridge::Login().

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

◆ Attn()

int XrdXrootdTransit::Attn ( XrdLink lP,
short *  theSID,
int  rcode,
const struct iovec *  ioVec,
int  ioNum,
int  ioLen 
)
static

Handle attention response (i.e. async response)

Definition at line 97 of file XrdXrootdTransit.cc.

99 {
100  XrdXrootdTransPend *tP;
101 
102 // Find the request
103 //
104  if (!(tP = XrdXrootdTransPend::Remove(lP, *theSID)))
105  {TRACE(REQ, "Unable to find request for " <<lP->ID <<" sid=" <<*theSID);
106  return 0;
107  }
108 
109 // Resume the request as we have been waiting for the response.
110 //
111  return tP->bridge->AttnCont(tP, rcode, ioV, ioN, ioL);
112 }
#define TRACE(act, x)
Definition: XrdTrace.hh:63
static XrdXrootdTransPend * Remove(XrdLink *lP, short sid)
XrdXrootdTransit * bridge

References XrdXrootdTransPend::bridge, XrdLink::ID, XrdXrootdTransPend::Remove(), and TRACE.

Referenced by XrdXrootdResponse::Send().

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

◆ Disc()

bool XrdXrootdTransit::Disc ( )
virtual

Handle dismantlement.

Implements XrdXrootd::Bridge.

Definition at line 158 of file XrdXrootdTransit.cc.

159 {
160  char buff[128];
161 
162 // We do not allow disconnection while we are active
163 //
164  if (runStatus.fetch_add(1, std::memory_order_acq_rel)) return false;
165 
166 // Reconnect original protocol to the link
167 //
168  Link->setProtocol(realProt);
169 
170 // Now we need to recycle our xrootd part
171 //
172  sprintf(buff, "%s disconnection", pName);
173  XrdXrootdProtocol::Recycle(Link, time(0)-cTime, buff);
174 
175 // Now just free up our object.
176 //
177  TranStack.Push(&TranLink);
178  return true;
179 }
void Push(XrdObject< T > *Node)
Definition: XrdObject.hh:101
void Recycle(XrdLink *lp, int consec, const char *reason) override

References XrdXrootdProtocol::Link, XrdObjectQ< T >::Push(), XrdXrootdProtocol::Recycle(), and XrdLink::setProtocol().

+ Here is the call graph for this function:

◆ Init()

void XrdXrootdTransit::Init ( XrdScheduler schedP,
int  qMax,
int  qTTL 
)
static

Perform one-time initialization.

Definition at line 208 of file XrdXrootdTransit.cc.

209 {
210  TranStack.Set(schedP, &XrdXrootdTrace, TRACE_MEM);
211  TranStack.Set(qMax, qTTL);
212 }
#define TRACE_MEM
Definition: XrdTrace.hh:38
XrdSysTrace XrdXrootdTrace
void Set(int inQMax, time_t agemax=1800)
Definition: XrdObject.icc:90
XrdScheduler * schedP

References XrdOfsPrepGPIReal::schedP, XrdObjectQ< T >::Set(), TRACE_MEM, and XrdXrootdTrace.

Referenced by Alloc(), and XrdXrootdProtocol::Configure().

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

◆ Proceed()

void XrdXrootdTransit::Proceed ( )

Resume processing after a waitresp completion.

Definition at line 326 of file XrdXrootdTransit.cc.

327 {
328  int rc;
329 
330 // If we were interrupted in a reinvoke state, resume that state.
331 //
332  if (reInvoke) rc = Process(Link);
333  else rc = 0;
334 
335 // Handle ending status
336 //
337  if (rc >= 0) Link->Enable();
338  else if (rc != -EINPROGRESS) Link->Close();
339 }
int Process(XrdLink *lp)
Handle link activation (replaces parent activation).

References XrdLink::Close(), XrdLink::Enable(), XrdXrootdProtocol::Link, and Process().

+ Here is the call graph for this function:

◆ Process()

int XrdXrootdTransit::Process ( XrdLink lp)
virtual

Handle link activation (replaces parent activation).

Reimplemented from XrdXrootdProtocol.

Definition at line 345 of file XrdXrootdTransit.cc.

346 {
347  int rc;
348 
349 // This entry is serialized via link processing and data is now available.
350 // One of the following will be returned.
351 //
352 // < 0 -> Stop getting requests,
353 // -EINPROGRESS leave link disabled but otherwise all is well
354 // -n Error, disable and close the link
355 // = 0 -> OK, get next request, if allowed, o/w enable the link
356 // > 0 -> Slow link, stop getting requests and enable the link
357 //
358 
359 // Reflect data is present to the underlying protocol and if Run() has been
360 // called we need to dispatch that request. This may be iterative.
361 //
362 do{rc = realProt->Process((reInvoke ? 0 : lp));
363  if (rc >= 0 && runStatus.load(std::memory_order_acquire))
364  {reInvoke = (rc == 0);
365  if (runError) rc = Fatal(rc);
366  else {runDone = false;
367  rc = (Resume ? XrdXrootdProtocol::Process(lp) : Process2());
368  if (rc >= 0)
369  {if (runWait) rc = -EINPROGRESS;
370  if (!runDone) return rc;
371  runStatus.store(0, std::memory_order_release);
372  }
373  }
374  } else reInvoke = false;
375  } while(rc >= 0 && reInvoke);
376 
377 // Make sure that we indicate that we are no longer active
378 //
379  runStatus.store(0, std::memory_order_release);
380 
381 // All done
382 //
383  return (rc ? rc : 1);
384 }
virtual int Process(XrdLink *lp)=0
int(XrdXrootdProtocol::* Resume)()
int Process(XrdLink *lp) override

References XrdXrootdProtocol::Process(), XrdProtocol::Process(), XrdXrootdProtocol::Process2(), and XrdXrootdProtocol::Resume.

Referenced by Proceed().

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

◆ Recycle()

void XrdXrootdTransit::Recycle ( XrdLink lp,
int  consec,
const char *  reason 
)
virtual

Handle link shutdown.

Reimplemented from XrdXrootdProtocol.

Definition at line 390 of file XrdXrootdTransit.cc.

391 {
392 
393 // Set ourselves as active so we can't get more requests
394 //
395  runStatus.fetch_add(1, std::memory_order_acq_rel);
396 
397 // If we were active then we will need to quiesce before dismantling ourselves.
398 // Note that Recycle() can only be called if the link is enabled. So, this bit
399 // of code is improbable but we check it anyway.
400 //
401  if (runWait > 0) {
402  TRACEP(EMSG, "WARNING: Recycle is canceling wait job; the wait job might already be running during recycle.");
403  Sched->Cancel(&waitJob);
404  }
405 
406 // First we need to recycle the real protocol
407 //
408  if (realProt) realProt->Recycle(lp, consec, reason);
409 
410 // Now we need to recycle our xrootd part
411 //
412  XrdXrootdProtocol::Recycle(lp, consec, reason);
413 
414 // Release the argument buffer
415 //
416  if (runArgs) {free(runArgs); runArgs = 0;}
417 
418 // Delete all pending requests
419 //
421 
422 // Now just free up our object.
423 //
424  TranStack.Push(&TranLink);
425 }
#define EMSG(x)
Definition: XrdCpConfig.cc:55
#define TRACEP(act, x)
virtual void Recycle(XrdLink *lp=0, int consec=0, const char *reason=0)=0
void Cancel(XrdJob *jp)
static XrdScheduler * Sched
static void Clear(XrdXrootdTransit *trP)

References XrdScheduler::Cancel(), XrdXrootdTransPend::Clear(), EMSG, XrdObjectQ< T >::Push(), XrdXrootdProtocol::Recycle(), XrdProtocol::Recycle(), XrdXrootdProtocol::Sched, and TRACEP.

+ Here is the call graph for this function:

◆ Redrive()

void XrdXrootdTransit::Redrive ( void  )

Redrive a request after a wait.

Definition at line 431 of file XrdXrootdTransit.cc.

432 {
433  static int eCode = htonl(kXR_NoMemory);
434  static char eText[] = "Insufficent memory to re-issue request";
435  static struct iovec ioV[] = {{(char *)&eCode,sizeof(eCode)},
436  {(char *)&eText,sizeof(eText)}};
437  int rc;
438 
439 // Do some tracing
440 //
441  TRACEP(REQ, "Bridge redrive runStatus="<<runStatus.load(std::memory_order_acquire)
442  <<" runError="<<runError
443  <<" runWait="<<runWait<<" runWTot="<<runWTot);
444 
445 // Update wait statistics
446 //
447  runWTot += runWait;
448  runWait = 0;
449 
450 // While we are running asynchronously, there is no way that this object can
451 // be deleted while a timer is outstanding as the link has been disabled. So,
452 // we can reissue the request with little worry.
453 //
454 // This is a bit tricky here as a redriven request may result in a wait. If
455 // this happens we cannot hand the result off to the real protocol until we
456 // wait and successfully redrive. The wait handling occurs asynchronously
457 // so all we need to do is honor it here.
458 //
459  if (!runALen || RunCopy(runArgs, runALen)) {
460  do{rc = Process2();
461  TRACEP(REQ, "Bridge redrive Process2 rc="<<rc
462  <<" runError="<<runError<<" runWait="<<runWait);
463  if (rc == 0 && !runWait && !runError) {
464  rc = realProt->Process(NULL);
465  TRACEP(REQ, "Bridge redrive callback rc="<<rc
466  <<" runStatus="<<runStatus.load(std::memory_order_acquire));
467  }
468  } while((rc == 0) && !runError && !runWait);
469  }
470  else rc = Send(kXR_error, ioV, 2, 0);
471 
472 // Defer the request if need be
473 //
474  if (rc >= 0 && runWait) return;
475  runWTot = 0;
476 
477 // Indicate we are no longer active
478 //
479  runStatus.store(0, std::memory_order_release);
480 
481 // If the link needs to be terminated, terminate the link. Otherwise, we can
482 // enable the link for new requests at this point.
483 //
484  if (rc < 0) Link->Close();
485  else Link->Enable();
486 }
@ kXR_NoMemory
Definition: XProtocol.hh:998
@ kXR_error
Definition: XProtocol.hh:903
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.

References XrdLink::Close(), XrdLink::Enable(), kXR_error, kXR_NoMemory, XrdXrootdProtocol::Link, XrdProtocol::Process(), XrdXrootdProtocol::Process2(), Send(), and TRACEP.

+ Here is the call graph for this function:

◆ ReqTable()

const char * XrdXrootdTransit::ReqTable ( )
static

Initialize the valid request table.

Definition at line 494 of file XrdXrootdTransit.cc.

495 {
496  static char rTab[kXR_truncate-kXR_auth+1];
497 
498 // Initialize the table
499 //
500  memset(rTab, 0, sizeof(rTab));
501  rTab[KXR_INDEX(kXR_chmod)] = 1;
502  rTab[KXR_INDEX(kXR_close)] = 1;
503  rTab[KXR_INDEX(kXR_dirlist)] = 1;
504  rTab[KXR_INDEX(kXR_locate)] = 1;
505  rTab[KXR_INDEX(kXR_mkdir)] = 1;
506  rTab[KXR_INDEX(kXR_mv)] = 1;
507  rTab[KXR_INDEX(kXR_open)] = 1;
508  rTab[KXR_INDEX(kXR_prepare)] = 1;
509  rTab[KXR_INDEX(kXR_protocol)] = 1;
510  rTab[KXR_INDEX(kXR_query)] = 1;
511  rTab[KXR_INDEX(kXR_read)] = 2;
512  rTab[KXR_INDEX(kXR_readv)] = 2;
513  rTab[KXR_INDEX(kXR_rm)] = 1;
514  rTab[KXR_INDEX(kXR_rmdir)] = 1;
515  rTab[KXR_INDEX(kXR_set)] = 1;
516  rTab[KXR_INDEX(kXR_stat)] = 1;
517  rTab[KXR_INDEX(kXR_statx)] = 1;
518  rTab[KXR_INDEX(kXR_sync)] = 1;
519  rTab[KXR_INDEX(kXR_truncate)] = 1;
520  rTab[KXR_INDEX(kXR_write)] = 2;
521 
522 // Now return the address
523 //
524  return rTab;
525 }
@ kXR_read
Definition: XProtocol.hh:125
@ kXR_open
Definition: XProtocol.hh:122
@ kXR_readv
Definition: XProtocol.hh:137
@ kXR_mkdir
Definition: XProtocol.hh:120
@ kXR_sync
Definition: XProtocol.hh:128
@ kXR_chmod
Definition: XProtocol.hh:114
@ kXR_dirlist
Definition: XProtocol.hh:116
@ kXR_rm
Definition: XProtocol.hh:126
@ kXR_query
Definition: XProtocol.hh:113
@ kXR_write
Definition: XProtocol.hh:131
@ kXR_auth
Definition: XProtocol.hh:112
@ kXR_set
Definition: XProtocol.hh:130
@ kXR_rmdir
Definition: XProtocol.hh:127
@ kXR_statx
Definition: XProtocol.hh:134
@ kXR_truncate
Definition: XProtocol.hh:140
@ kXR_protocol
Definition: XProtocol.hh:118
@ kXR_mv
Definition: XProtocol.hh:121
@ kXR_stat
Definition: XProtocol.hh:129
@ kXR_locate
Definition: XProtocol.hh:139
@ kXR_close
Definition: XProtocol.hh:115
@ kXR_prepare
Definition: XProtocol.hh:133
#define KXR_INDEX(x)

References kXR_auth, kXR_chmod, kXR_close, kXR_dirlist, KXR_INDEX, kXR_locate, kXR_mkdir, kXR_mv, kXR_open, kXR_prepare, kXR_protocol, kXR_query, kXR_read, kXR_readv, kXR_rm, kXR_rmdir, kXR_set, kXR_stat, kXR_statx, kXR_sync, kXR_truncate, and kXR_write.

◆ Run()

bool XrdXrootdTransit::Run ( const char *  xreqP,
char *  xdataP = 0,
int  xdataL = 0 
)
virtual

Inject an xrootd request into the protocol stack.

Parameters
xreqPxrootd request header
xdataPxrootd request data (optional)
xdataLxrootd request data length

Implements XrdXrootd::Bridge.

Definition at line 558 of file XrdXrootdTransit.cc.

559 {
560  int movLen;
561 
562 // We do not allow re-entry if we are curently processing a request.
563 // It will be reset, as need, when a response is effected.
564 //
565 
566  if (runStatus.fetch_add(1, std::memory_order_acq_rel))
567  {TRACEP(REQ, "Bridge request failed due to re-entry");
568  return false;
569  }
570 
571 // Copy the request header
572 //
573  memcpy((void *)&Request, (void *)xreqP, sizeof(Request));
574 
575 // Validate that we can actually handle this request
576 //
578  if (Request.header.requestid & 0x8000
579  || Request.header.requestid > static_cast<kXR_unt16>(kXR_truncate)
580  || !reqTab[Request.header.requestid - kXR_auth])
581  {TRACEP(REQ, "Unsupported bridge request");
582  return Fail(kXR_Unsupported, "Unsupported bridge request");
583  }
584 
585 // Validate the data length
586 //
588  if (Request.header.dlen < 0)
589  {TRACEP(REQ, "Invalid request data length");
590  return Fail(kXR_ArgInvalid, "Invalid request data length");
591  }
592 
593 // Copy the stream id and trace this request
594 //
596  TRACEP(REQ, "Bridge req=" <<Request.header.requestid
597  <<" dlen=" <<Request.header.dlen <<" blen=" <<xdataL);
598 
599 // If this is a write request, we will need to do a lot more
600 //
601  if (Request.header.requestid == kXR_write) return ReqWrite(xdataP, xdataL);
602 
603 // Obtain any needed buffer and handle any existing data arguments. Also, we
604 // need to keep a shadow copy of the request arguments should we get a wait
605 // and will need to re-issue the request (the server mangles the args).
606 //
607  if (Request.header.dlen)
608  {movLen = (xdataL < Request.header.dlen ? xdataL : Request.header.dlen);
609  if (!RunCopy(xdataP, movLen)) return true;
610  if (!runArgs || movLen > runABsz)
611  {if (runArgs) free(runArgs);
612  if (!(runArgs = (char *)malloc(movLen)))
613  {TRACEP(REQ, "Failed to allocate memory");
614  return Fail(kXR_NoMemory, "Insufficient memory");
615  }
616  runABsz = movLen;
617  }
618  memcpy(runArgs, xdataP, movLen); runALen = movLen;
619  if ((myBlen = Request.header.dlen - movLen))
620  {myBuff = argp->buff + movLen;
622  return true;
623  }
624  } else runALen = 0;
625 
626 // If we have all the data, indicate request accepted.
627 //
628  runError = 0;
629  Resume = 0;
630  return true;
631 }
@ kXR_ArgInvalid
Definition: XProtocol.hh:990
@ kXR_Unsupported
Definition: XProtocol.hh:1003
kXR_char streamid[2]
Definition: XProtocol.hh:156
struct ClientRequestHdr header
Definition: XProtocol.hh:846
kXR_unt16 requestid
Definition: XProtocol.hh:157
kXR_int32 dlen
Definition: XProtocol.hh:159
unsigned short kXR_unt16
Definition: XPtypes.hh:67
char * buff
Definition: XrdBuffer.hh:45
XrdXrootdResponse Response
void Set(XrdLink *lp)

References XrdXrootdProtocol::argp, XrdBuffer::buff, ClientRequestHdr::dlen, ClientRequest::header, kXR_ArgInvalid, kXR_auth, kXR_NoMemory, kXR_truncate, kXR_Unsupported, kXR_write, XrdXrootdProtocol::myBlen, XrdXrootdProtocol::myBuff, XrdXrootdProtocol::Process2(), XrdXrootdProtocol::Request, ClientRequestHdr::requestid, XrdXrootdProtocol::Response, XrdXrootdProtocol::Resume, XrdXrootdResponse::Set(), ClientRequestHdr::streamid, and TRACEP.

+ Here is the call graph for this function:

◆ Send() [1/3]

int XrdXrootdTransit::Send ( int  rcode,
const struct iovec *  ioVec,
int  ioNum,
int  ioLen 
)

Handle request data response.

Definition at line 660 of file XrdXrootdTransit.cc.

661 {
664  const char *eMsg;
665  int rc;
666  bool aOK;
667 
668 // Invoke the result object (we initially assume this is the final result)
669 //
670  runDone = true;
671  switch(rcode)
672  {case kXR_error:
673  rc = XRD_GETNUM(ioV[0].iov_base);
674  eMsg = (ioN < 2 ? "" : (const char *)ioV[1].iov_base);
675  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
676  aOK = respObj->Error(rInfo, rc, eMsg);
677  break;
678  case kXR_ok:
679  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
680  aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL, true)
681  : respObj->Done(rInfo));
682  break;
683  case kXR_oksofar:
684  aOK = respObj->Data(rInfo, ioV, ioN, ioL, false);
685  runDone = false;
686  break;
687  case kXR_redirect:
688  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
689  rc = XRD_GETNUM(ioV[0].iov_base);
690  aOK = respObj->Redir(rInfo,rc,(const char *)ioV[1].iov_base);
691  break;
692  case kXR_wait:
693  return Wait(rInfo, ioV, ioN, ioL);
694  break;
695  case kXR_waitresp:
696  runDone = false;
697  return WaitResp(rInfo, ioV, ioN, ioL);
698  break;
699  default: if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
700  aOK = respObj->Error(rInfo, kXR_ServerError,
701  "internal logic error");
702  break;
703  };
704 
705 // All done
706 //
707  return (aOK ? 0 : -1);
708 }
@ kXR_ServerError
Definition: XProtocol.hh:1002
@ kXR_waitresp
Definition: XProtocol.hh:906
@ kXR_redirect
Definition: XProtocol.hh:904
@ kXR_oksofar
Definition: XProtocol.hh:900
@ kXR_ok
Definition: XProtocol.hh:899
@ kXR_wait
Definition: XProtocol.hh:905
#define eMsg(x)
#define XRD_GETNUM(x)
virtual bool Data(Bridge::Context &info, const struct iovec *iovP, int iovN, int iovL, bool final)=0
virtual bool Error(Bridge::Context &info, int ecode, const char *etext)=0
virtual bool Done(Bridge::Context &info)=0
the result context
virtual bool Redir(Bridge::Context &info, int port, const char *hname)=0
virtual void Free(Bridge::Context &info, char *buffP, int buffL)

References XrdXrootd::Bridge::Result::Data(), XrdXrootd::Bridge::Result::Done(), eMsg, XrdXrootd::Bridge::Result::Error(), XrdXrootd::Bridge::Result::Free(), ClientRequest::header, kXR_error, kXR_ok, kXR_oksofar, kXR_redirect, kXR_ServerError, kXR_wait, kXR_waitresp, XrdXrootdProtocol::Link, XrdXrootd::Bridge::Result::Redir(), XrdXrootdProtocol::Request, ClientRequestHdr::requestid, ClientRequestHdr::streamid, and XRD_GETNUM.

Referenced by Redrive(), and XrdXrootdResponse::Send().

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

◆ Send() [2/3]

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

Handle request sendfile response.

Definition at line 712 of file XrdXrootdTransit.cc.

713 {
716  offset, dlen, fdnum);
717 
718 // Effect callback (this is always a final result)
719 //
720  runDone = true;
721  return (respObj->File(sfInfo, dlen) ? 0 : -1);
722 }
virtual int File(Bridge::Context &info, int dlen)=0

References XrdXrootd::Bridge::Result::File(), ClientRequest::header, XrdXrootdProtocol::Link, XrdXrootdProtocol::Request, ClientRequestHdr::requestid, and ClientRequestHdr::streamid.

+ Here is the call graph for this function:

◆ Send() [3/3]

int XrdXrootdTransit::Send ( XrdOucSFVec sfvec,
int  sfvnum,
int  dlen 
)

Definition at line 726 of file XrdXrootdTransit.cc.

727 {
730  sfvec, sfvnum, dlen);
731 
732 // Effect callback (this is always a final result)
733 //
734  runDone = true;
735  return (respObj->File(sfInfo, dlen) ? 0 : -1);
736 }

References XrdXrootd::Bridge::Result::File(), ClientRequest::header, XrdXrootdProtocol::Link, XrdXrootdProtocol::Request, ClientRequestHdr::requestid, and ClientRequestHdr::streamid.

+ Here is the call graph for this function:

◆ setSF()

int XrdXrootdTransit::setSF ( kXR_char fhandle,
bool  seton = false 
)
inlinevirtual

Set sendfile() enablement.

Implements XrdXrootd::Bridge.

Definition at line 148 of file XrdXrootdTransit.hh.

149  {return SetSF(fhandle, seton);}
int SetSF(kXR_char *fhandle, bool seton=false)

References XrdXrootdProtocol::SetSF().

+ Here is the call graph for this function:

◆ SetWait()

void XrdXrootdTransit::SetWait ( int  wtime,
bool  notify = false 
)
inlinevirtual

Set maximum wait time.

Implements XrdXrootd::Bridge.

Definition at line 155 of file XrdXrootdTransit.hh.

156  {runWMax = wtime; runWCall = notify;}

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