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 52 of file XrdXrootdTransit.hh.

Constructor & Destructor Documentation

◆ XrdXrootdTransit()

XrdXrootdTransit::XrdXrootdTransit ( )
inline

Constructor & Destructor.

Definition at line 159 of file XrdXrootdTransit.hh.

159  : TranLink(this),
160  respJob(this, &XrdXrootdTransit::Proceed,
161  "Transit proceed"),
162  waitJob(this, &XrdXrootdTransit::Redrive,
163  "Transit redrive")
164  {}
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 165 of file XrdXrootdTransit.hh.

165 {}

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 162 of file XrdXrootdTransit.cc.

163 {
164  char buff[128];
165  int rc;
166 
167 // We do not allow disconnection while we are active
168 //
169  AtomicBeg(runMutex);
170  rc = AtomicInc(runStatus);
171  AtomicEnd(runMutex);
172  if (rc) return false;
173 
174 // Reconnect original protocol to the link
175 //
176  Link->setProtocol(realProt);
177 
178 // Now we need to recycle our xrootd part
179 //
180  sprintf(buff, "%s disconnection", pName);
181  XrdXrootdProtocol::Recycle(Link, time(0)-cTime, buff);
182 
183 // Now just free up our object.
184 //
185  TranStack.Push(&TranLink);
186  return true;
187 }
#define AtomicInc(x)
#define AtomicBeg(Mtx)
#define AtomicEnd(Mtx)
void Push(XrdObject< T > *Node)
Definition: XrdObject.hh:101
void Recycle(XrdLink *lp, int consec, const char *reason) override

References AtomicBeg, AtomicEnd, AtomicInc, 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 216 of file XrdXrootdTransit.cc.

217 {
218  TranStack.Set(schedP, &XrdXrootdTrace, TRACE_MEM);
219  TranStack.Set(qMax, qTTL);
220 }
#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 334 of file XrdXrootdTransit.cc.

335 {
336  int rc;
337 
338 // If we were interrupted in a reinvoke state, resume that state.
339 //
340  if (reInvoke) rc = Process(Link);
341  else rc = 0;
342 
343 // Handle ending status
344 //
345  if (rc >= 0) Link->Enable();
346  else if (rc != -EINPROGRESS) Link->Close();
347 }
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 353 of file XrdXrootdTransit.cc.

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

References AtomicBeg, AtomicEnd, AtomicZAP, 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 404 of file XrdXrootdTransit.cc.

405 {
406 
407 // Set ourselves as active so we can't get more requests
408 //
409  AtomicBeg(runMutex);
410  AtomicInc(runStatus);
411  AtomicEnd(runMutex);
412 
413 // If we were active then we will need to quiesce before dismantling ourselves.
414 // Note that Recycle() can only be called if the link is enabled. So, this bit
415 // of code is improbable but we check it anyway.
416 //
417  if (runWait > 0) Sched->Cancel(&waitJob);
418 
419 // First we need to recycle the real protocol
420 //
421  if (realProt) realProt->Recycle(lp, consec, reason);
422 
423 // Now we need to recycle our xrootd part
424 //
425  XrdXrootdProtocol::Recycle(lp, consec, reason);
426 
427 // Release the argument buffer
428 //
429  if (runArgs) {free(runArgs); runArgs = 0;}
430 
431 // Delete all pending requests
432 //
434 
435 // Now just free up our object.
436 //
437  TranStack.Push(&TranLink);
438 }
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 AtomicBeg, AtomicEnd, AtomicInc, XrdScheduler::Cancel(), XrdXrootdTransPend::Clear(), XrdObjectQ< T >::Push(), XrdXrootdProtocol::Recycle(), XrdProtocol::Recycle(), and XrdXrootdProtocol::Sched.

+ Here is the call graph for this function:

◆ Redrive()

void XrdXrootdTransit::Redrive ( void  )

Redrive a request after a wait.

Definition at line 444 of file XrdXrootdTransit.cc.

445 {
446  static int eCode = htonl(kXR_NoMemory);
447  static char eText[] = "Insufficent memory to re-issue request";
448  static struct iovec ioV[] = {{(char *)&eCode,sizeof(eCode)},
449  {(char *)&eText,sizeof(eText)}};
450  int rc;
451 
452 // Update wait statistics
453 //
454  runWTot += runWait;
455  runWait = 0;
456 
457 // While we are running asynchronously, there is no way that this object can
458 // be deleted while a timer is outstanding as the link has been disabled. So,
459 // we can reissue the request with little worry.
460 //
461  if (!runALen || RunCopy(runArgs, runALen)) {
462  do{rc = Process2();
463  if (rc == 0) {
464  rc = realProt->Process(NULL);
465  }
466  if (runStatus)
467  {AtomicBeg(runMutex);
468  AtomicZAP(runStatus);
469  AtomicEnd(runMutex);
470  }
471  } while((rc == 0) && !runError && !runWait);
472  }
473  else rc = Send(kXR_error, ioV, 2, 0);
474 
475 // Defer the request if need be
476 //
477  if (rc >= 0 && runWait) return;
478  runWTot = 0;
479 
480 // Indicate we are no longer active
481 //
482  if (runStatus)
483  {AtomicBeg(runMutex);
484  AtomicZAP(runStatus);
485  AtomicEnd(runMutex);
486  }
487 
488 // If the link needs to be terminated, terminate the link. Otherwise, we can
489 // enable the link for new requests at this point.
490 //
491  if (rc < 0) Link->Close();
492  else Link->Enable();
493 }
@ 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 AtomicBeg, AtomicEnd, AtomicZAP, XrdLink::Close(), XrdLink::Enable(), kXR_error, kXR_NoMemory, XrdXrootdProtocol::Link, XrdProtocol::Process(), XrdXrootdProtocol::Process2(), and Send().

+ Here is the call graph for this function:

◆ ReqTable()

const char * XrdXrootdTransit::ReqTable ( )
static

Initialize the valid request table.

Definition at line 501 of file XrdXrootdTransit.cc.

502 {
503  static char rTab[kXR_truncate-kXR_auth+1];
504 
505 // Initialize the table
506 //
507  memset(rTab, 0, sizeof(rTab));
508  rTab[KXR_INDEX(kXR_chmod)] = 1;
509  rTab[KXR_INDEX(kXR_close)] = 1;
510  rTab[KXR_INDEX(kXR_dirlist)] = 1;
511  rTab[KXR_INDEX(kXR_locate)] = 1;
512  rTab[KXR_INDEX(kXR_mkdir)] = 1;
513  rTab[KXR_INDEX(kXR_mv)] = 1;
514  rTab[KXR_INDEX(kXR_open)] = 1;
515  rTab[KXR_INDEX(kXR_prepare)] = 1;
516  rTab[KXR_INDEX(kXR_protocol)] = 1;
517  rTab[KXR_INDEX(kXR_query)] = 1;
518  rTab[KXR_INDEX(kXR_read)] = 2;
519  rTab[KXR_INDEX(kXR_readv)] = 2;
520  rTab[KXR_INDEX(kXR_rm)] = 1;
521  rTab[KXR_INDEX(kXR_rmdir)] = 1;
522  rTab[KXR_INDEX(kXR_set)] = 1;
523  rTab[KXR_INDEX(kXR_stat)] = 1;
524  rTab[KXR_INDEX(kXR_statx)] = 1;
525  rTab[KXR_INDEX(kXR_sync)] = 1;
526  rTab[KXR_INDEX(kXR_truncate)] = 1;
527  rTab[KXR_INDEX(kXR_write)] = 2;
528 
529 // Now return the address
530 //
531  return rTab;
532 }
@ 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 565 of file XrdXrootdTransit.cc.

566 {
567  int movLen, rc;
568 
569 // We do not allow re-entry if we are curently processing a request.
570 // It will be reset, as need, when a response is effected.
571 //
572  AtomicBeg(runMutex);
573  rc = AtomicInc(runStatus);
574  AtomicEnd(runMutex);
575  if (rc)
576  {TRACEP(REQ, "Bridge request failed due to re-entry");
577  return false;
578  }
579 
580 // Copy the request header
581 //
582  memcpy((void *)&Request, (void *)xreqP, sizeof(Request));
583 
584 // Validate that we can actually handle this request
585 //
587  if (Request.header.requestid & 0x8000
588  || Request.header.requestid > static_cast<kXR_unt16>(kXR_truncate)
589  || !reqTab[Request.header.requestid - kXR_auth])
590  {TRACEP(REQ, "Unsupported bridge request");
591  return Fail(kXR_Unsupported, "Unsupported bridge request");
592  }
593 
594 // Validate the data length
595 //
597  if (Request.header.dlen < 0)
598  {TRACEP(REQ, "Invalid request data length");
599  return Fail(kXR_ArgInvalid, "Invalid request data length");
600  }
601 
602 // Copy the stream id and trace this request
603 //
605  TRACEP(REQ, "Bridge req=" <<Request.header.requestid
606  <<" dlen=" <<Request.header.dlen <<" blen=" <<xdataL);
607 
608 // If this is a write request, we will need to do a lot more
609 //
610  if (Request.header.requestid == kXR_write) return ReqWrite(xdataP, xdataL);
611 
612 // Obtain any needed buffer and handle any existing data arguments. Also, we
613 // need to keep a shadow copy of the request arguments should we get a wait
614 // and will need to re-issue the request (the server mangles the args).
615 //
616  if (Request.header.dlen)
617  {movLen = (xdataL < Request.header.dlen ? xdataL : Request.header.dlen);
618  if (!RunCopy(xdataP, movLen)) return true;
619  if (!runArgs || movLen > runABsz)
620  {if (runArgs) free(runArgs);
621  if (!(runArgs = (char *)malloc(movLen)))
622  {TRACEP(REQ, "Failed to allocate memory");
623  return Fail(kXR_NoMemory, "Insufficient memory");
624  }
625  runABsz = movLen;
626  }
627  memcpy(runArgs, xdataP, movLen); runALen = movLen;
628  if ((myBlen = Request.header.dlen - movLen))
629  {myBuff = argp->buff + movLen;
631  return true;
632  }
633  } else runALen = 0;
634 
635 // If we have all the data, indicate request accepted.
636 //
637  runError = 0;
638  Resume = 0;
639  return true;
640 }
@ 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
#define TRACEP(act, x)
char * buff
Definition: XrdBuffer.hh:45
XrdXrootdResponse Response
void Set(XrdLink *lp)

References XrdXrootdProtocol::argp, AtomicBeg, AtomicEnd, AtomicInc, 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 669 of file XrdXrootdTransit.cc.

670 {
673  const char *eMsg;
674  int rc;
675  bool aOK;
676 
677 // Invoke the result object (we initially assume this is the final result)
678 //
679  runDone = true;
680  switch(rcode)
681  {case kXR_error:
682  rc = XRD_GETNUM(ioV[0].iov_base);
683  eMsg = (ioN < 2 ? "" : (const char *)ioV[1].iov_base);
684  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
685  aOK = respObj->Error(rInfo, rc, eMsg);
686  break;
687  case kXR_ok:
688  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
689  aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL, true)
690  : respObj->Done(rInfo));
691  break;
692  case kXR_oksofar:
693  aOK = respObj->Data(rInfo, ioV, ioN, ioL, false);
694  runDone = false;
695  break;
696  case kXR_redirect:
697  if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
698  rc = XRD_GETNUM(ioV[0].iov_base);
699  aOK = respObj->Redir(rInfo,rc,(const char *)ioV[1].iov_base);
700  break;
701  case kXR_wait:
702  return Wait(rInfo, ioV, ioN, ioL);
703  break;
704  case kXR_waitresp:
705  runDone = false;
706  return WaitResp(rInfo, ioV, ioN, ioL);
707  break;
708  default: if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
709  aOK = respObj->Error(rInfo, kXR_ServerError,
710  "internal logic error");
711  break;
712  };
713 
714 // All done
715 //
716  return (aOK ? 0 : -1);
717 }
@ 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 721 of file XrdXrootdTransit.cc.

722 {
725  offset, dlen, fdnum);
726 
727 // Effect callback (this is always a final result)
728 //
729  runDone = true;
730  return (respObj->File(sfInfo, dlen) ? 0 : -1);
731 }
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 735 of file XrdXrootdTransit.cc.

736 {
739  sfvec, sfvnum, dlen);
740 
741 // Effect callback (this is always a final result)
742 //
743  runDone = true;
744  return (respObj->File(sfInfo, dlen) ? 0 : -1);
745 }

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 145 of file XrdXrootdTransit.hh.

146  {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 152 of file XrdXrootdTransit.hh.

153  {runWMax = wtime; runWCall = notify;}

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