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

#include <XrdXrootdTransit.hh>

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

Public Member Functions

 XrdXrootdTransit ()
 Constructor & Destructor.
 
virtual ~XrdXrootdTransit ()
 
bool Disc ()
 Handle dismantlement.
 
void Proceed ()
 Resume processing after a waitresp completion.
 
int Process (XrdLink *lp)
 Handle link activation (replaces parent activation).
 
void Recycle (XrdLink *lp, int consec, const char *reason)
 Handle link shutdown.
 
void Redrive ()
 Redrive a request after a wait.
 
bool Run (const char *xreqP, char *xdataP=0, int xdataL=0)
 Inject an xrootd request into the protocol stack.
 
int Send (int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
 Handle request data response.
 
int Send (long long offset, int dlen, int fdnum)
 Handle request sendfile response.
 
int Send (XrdOucSFVec *sfvec, int sfvnum, int dlen)
 
int setSF (kXR_char *fhandle, bool seton=false)
 Set sendfile() enablement.
 
void SetWait (int wtime, bool notify=false)
 Set maximum wait time.
 
- Public Member Functions inherited from XrdXrootd::Bridge
 Bridge ()
 Constructor & Destructor.
 
- 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.
 
virtual ~XrdSfsDio ()
 
- Public Member Functions inherited from XrdSfsXio
 XrdSfsXio (XrdSfsXioImpl &xioimpl)
 
virtual ~XrdSfsXio ()
 Constructor and destructor.
 

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.
 
static int Attn (XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
 Handle attention response (i.e. async response)
 
static void Init (XrdScheduler *schedP, int qMax, int qTTL)
 Perform one-time initialization.
 
static const char * ReqTable ()
 Initialize the valid request table.
 
- 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.

References XrdXrootdTransit(), Proceed(), and Redrive().

Referenced by XrdXrootdTransit(), and Alloc().

+ Here is the call graph for this function:
+ 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{
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}
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
XrdXrootdTransit()
Constructor & Destructor.

References XrdXrootdTransit(), and Init().

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 Recycle(XrdLink *lp, int consec, const char *reason) override

References AtomicBeg, AtomicEnd, AtomicInc, XrdXrootdProtocol::Link, and XrdXrootdProtocol::Recycle().

+ 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}
XrdOucTrace * XrdXrootdTrace
#define TRACE_MEM
Definition XrdTrace.hh:38

References TRACE_MEM, XrdJob::XrdScheduler, 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 XrdXrootdProtocol::Link, and Process().

Referenced by XrdXrootdTransit().

+ Here is the call graph for this function:
+ Here is the caller 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//
370do{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;
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)
int(XrdXrootdProtocol::* Resume)()
int Process(XrdLink *lp) override

References AtomicBeg, AtomicEnd, AtomicZAP, XrdXrootdProtocol::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}
static XrdScheduler * Sched
static void Clear(XrdXrootdTransit *trP)

References AtomicBeg, AtomicEnd, AtomicInc, XrdXrootdTransPend::Clear(), XrdXrootdProtocol::Recycle(), and XrdXrootdProtocol::Sched.

+ Here is the call graph for this function:

◆ Redrive()

void XrdXrootdTransit::Redrive ( )

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// Do some tracing
453//
454 TRACEP(REQ, "Bridge redrive runStatus="<<runStatus<<" runError="<<runError
455 <<" runWait="<<runWait<<" runWTot="<<runWTot);
456
457// Update wait statistics
458//
459 runWTot += runWait;
460 runWait = 0;
461
462// While we are running asynchronously, there is no way that this object can
463// be deleted while a timer is outstanding as the link has been disabled. So,
464// we can reissue the request with little worry.
465//
466// This is a bit tricky here as a redriven request may result in a wait. If
467// this happens we cannot hand the result off to the real protocol until we
468// wait and successfully redrive. The wait handling occurs asynchronously
469// so all we need to do is honor it here.
470//
471 if (!runALen || RunCopy(runArgs, runALen)) {
472 do{rc = Process2();
473 TRACEP(REQ, "Bridge redrive Process2 rc="<<rc
474 <<" runError="<<runError<<" runWait="<<runWait);
475 if (rc == 0 && !runWait && !runError) {
476 rc = realProt->Process(NULL);
477 TRACEP(REQ, "Bridge redrive callback rc="<<rc
478 <<" runStatus="<<runStatus);
479 }
480 if (runStatus)
481 {AtomicBeg(runMutex);
482 AtomicZAP(runStatus);
483 AtomicEnd(runMutex);
484 }
485 } while((rc == 0) && !runError && !runWait);
486 }
487 else rc = Send(kXR_error, ioV, 2, 0);
488
489// Defer the request if need be
490//
491 if (rc >= 0 && runWait) return;
492 runWTot = 0;
493
494// Indicate we are no longer active
495//
496 if (runStatus)
497 {AtomicBeg(runMutex);
498 AtomicZAP(runStatus);
499 AtomicEnd(runMutex);
500 }
501
502// If the link needs to be terminated, terminate the link. Otherwise, we can
503// enable the link for new requests at this point.
504//
505 if (rc < 0) Link->Close();
506 else Link->Enable();
507}
@ kXR_NoMemory
Definition XProtocol.hh:998
@ kXR_error
Definition XProtocol.hh:903
#define TRACEP(act, x)
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.

References AtomicBeg, AtomicEnd, AtomicZAP, kXR_error, kXR_NoMemory, XrdXrootdProtocol::Link, XrdXrootdProtocol::Process2(), Send(), and TRACEP.

Referenced by XrdXrootdTransit().

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

◆ ReqTable()

const char * XrdXrootdTransit::ReqTable ( )
static

Initialize the valid request table.

Definition at line 515 of file XrdXrootdTransit.cc.

516{
517 static char rTab[kXR_truncate-kXR_auth+1];
518
519// Initialize the table
520//
521 memset(rTab, 0, sizeof(rTab));
522 rTab[KXR_INDEX(kXR_chmod)] = 1;
523 rTab[KXR_INDEX(kXR_close)] = 1;
524 rTab[KXR_INDEX(kXR_dirlist)] = 1;
525 rTab[KXR_INDEX(kXR_locate)] = 1;
526 rTab[KXR_INDEX(kXR_mkdir)] = 1;
527 rTab[KXR_INDEX(kXR_mv)] = 1;
528 rTab[KXR_INDEX(kXR_open)] = 1;
529 rTab[KXR_INDEX(kXR_prepare)] = 1;
530 rTab[KXR_INDEX(kXR_protocol)] = 1;
531 rTab[KXR_INDEX(kXR_query)] = 1;
532 rTab[KXR_INDEX(kXR_read)] = 2;
533 rTab[KXR_INDEX(kXR_readv)] = 2;
534 rTab[KXR_INDEX(kXR_rm)] = 1;
535 rTab[KXR_INDEX(kXR_rmdir)] = 1;
536 rTab[KXR_INDEX(kXR_set)] = 1;
537 rTab[KXR_INDEX(kXR_stat)] = 1;
538 rTab[KXR_INDEX(kXR_statx)] = 1;
539 rTab[KXR_INDEX(kXR_sync)] = 1;
540 rTab[KXR_INDEX(kXR_truncate)] = 1;
541 rTab[KXR_INDEX(kXR_write)] = 2;
542
543// Now return the address
544//
545 return rTab;
546}
@ 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 579 of file XrdXrootdTransit.cc.

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

References XrdXrootdProtocol::argp, AtomicBeg, AtomicEnd, AtomicInc, kXR_ArgInvalid, kXR_auth, kXR_NoMemory, kXR_truncate, kXR_Unsupported, kXR_write, XrdXrootdProtocol::myBlen, XrdXrootdProtocol::myBuff, XrdXrootdProtocol::Process2(), XrdXrootdProtocol::Request, XrdXrootdProtocol::Response, XrdXrootdProtocol::Resume, 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 683 of file XrdXrootdTransit.cc.

684{
685 XrdXrootd::Bridge::Context rInfo(Link, Request.header.streamid,
686 Request.header.requestid);
687 const char *eMsg;
688 int rc;
689 bool aOK;
690
691// Invoke the result object (we initially assume this is the final result)
692//
693 runDone = true;
694 switch(rcode)
695 {case kXR_error:
696 rc = XRD_GETNUM(ioV[0].iov_base);
697 eMsg = (ioN < 2 ? "" : (const char *)ioV[1].iov_base);
698 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
699 aOK = respObj->Error(rInfo, rc, eMsg);
700 break;
701 case kXR_ok:
702 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
703 aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL, true)
704 : respObj->Done(rInfo));
705 break;
706 case kXR_oksofar:
707 aOK = respObj->Data(rInfo, ioV, ioN, ioL, false);
708 runDone = false;
709 break;
710 case kXR_redirect:
711 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
712 rc = XRD_GETNUM(ioV[0].iov_base);
713 aOK = respObj->Redir(rInfo,rc,(const char *)ioV[1].iov_base);
714 break;
715 case kXR_wait:
716 return Wait(rInfo, ioV, ioN, ioL);
717 break;
718 case kXR_waitresp:
719 runDone = false;
720 return WaitResp(rInfo, ioV, ioN, ioL);
721 break;
722 default: if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
723 aOK = respObj->Error(rInfo, kXR_ServerError,
724 "internal logic error");
725 break;
726 };
727
728// All done
729//
730 return (aOK ? 0 : -1);
731}
@ kXR_ServerError
@ 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)

References eMsg, kXR_error, kXR_ok, kXR_oksofar, kXR_redirect, kXR_ServerError, kXR_wait, kXR_waitresp, XrdXrootdProtocol::Link, XrdXrootdProtocol::Request, and XRD_GETNUM.

Referenced by Redrive().

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

736{
737 XrdXrootdTransSend sfInfo(Link, Request.header.streamid,
738 Request.header.requestid,
739 offset, dlen, fdnum);
740
741// Effect callback (this is always a final result)
742//
743 runDone = true;
744 return (respObj->File(sfInfo, dlen) ? 0 : -1);
745}

References XrdXrootdProtocol::Link, and XrdXrootdProtocol::Request.

◆ Send() [3/3]

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

Definition at line 749 of file XrdXrootdTransit.cc.

750{
751 XrdXrootdTransSend sfInfo(Link, Request.header.streamid,
752 Request.header.requestid,
753 sfvec, sfvnum, dlen);
754
755// Effect callback (this is always a final result)
756//
757 runDone = true;
758 return (respObj->File(sfInfo, dlen) ? 0 : -1);
759}

References XrdXrootdProtocol::Link, and XrdXrootdProtocol::Request.

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