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.

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{
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{
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}
XrdOucTrace * XrdXrootdTrace
#define TRACE_MEM
Definition XrdTrace.hh:38
void Set(int inQMax, time_t agemax=1800)
Definition XrdObject.icc:90

References 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//
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)
virtual int Process(XrdLink *lp)=0
int(XrdXrootdProtocol::* Resume)()
int Process(XrdLink *lp) override

References AtomicBeg, AtomicEnd, AtomicZAP, XrdProtocol::Process(), 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}
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(), XrdProtocol::Recycle(), 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// 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 } while((rc == 0) && !runError && !runWait);
467 }
468 else rc = Send(kXR_error, ioV, 2, 0);
469
470// Defer the request if need be
471//
472 if (rc >= 0 && runWait) return;
473 runWTot = 0;
474
475// Indicate we are no longer active
476//
477 if (runStatus)
478 {AtomicBeg(runMutex);
479 AtomicZAP(runStatus);
480 AtomicEnd(runMutex);
481 }
482
483// If the link needs to be terminated, terminate the link. Otherwise, we can
484// enable the link for new requests at this point.
485//
486 if (rc < 0) Link->Close();
487 else Link->Enable();
488}
@ 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 496 of file XrdXrootdTransit.cc.

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

561{
562 int movLen, rc;
563
564// We do not allow re-entry if we are curently processing a request.
565// It will be reset, as need, when a response is effected.
566//
567 AtomicBeg(runMutex);
568 rc = AtomicInc(runStatus);
569 AtomicEnd(runMutex);
570 if (rc) return false;
571
572// Copy the request header
573//
574 memcpy((void *)&Request, (void *)xreqP, sizeof(Request));
575
576// Validate that we can actually handle this request
577//
579 if (Request.header.requestid & 0x8000
581 || !reqTab[Request.header.requestid - kXR_auth])
582 return Fail(kXR_Unsupported, "Unsupported bridge request");
583
584// Validate the data length
585//
587 if (Request.header.dlen < 0)
588 return Fail(kXR_ArgInvalid, "Invalid request data length");
589
590// Copy the stream id and trace this request
591//
593 TRACEP(REQ, "Bridge req=" <<Request.header.requestid
594 <<" dlen=" <<Request.header.dlen <<" blen=" <<xdataL);
595
596// If this is a write request, we will need to do a lot more
597//
598 if (Request.header.requestid == kXR_write) return ReqWrite(xdataP, xdataL);
599
600// Obtain any needed buffer and handle any existing data arguments. Also, we
601// need to keep a shadow copy of the request arguments should we get a wait
602// and will need to re-issue the request (the server mangles the args).
603//
604 if (Request.header.dlen)
605 {movLen = (xdataL < Request.header.dlen ? xdataL : Request.header.dlen);
606 if (!RunCopy(xdataP, movLen)) return true;
607 if (!runArgs || movLen > runABsz)
608 {if (runArgs) free(runArgs);
609 if (!(runArgs = (char *)malloc(movLen)))
610 return Fail(kXR_NoMemory, "Insufficient memory");
611 runABsz = movLen;
612 }
613 memcpy(runArgs, xdataP, movLen); runALen = movLen;
614 if ((myBlen = Request.header.dlen - movLen))
615 {myBuff = argp->buff + movLen;
617 return true;
618 }
619 } else runALen = 0;
620
621// If we have all the data, indicate request accepted.
622//
623 runError = 0;
624 Resume = 0;
625 return true;
626}
@ kXR_ArgInvalid
Definition XProtocol.hh:990
@ kXR_Unsupported
kXR_char streamid[2]
Definition XProtocol.hh:156
struct ClientRequestHdr header
Definition XProtocol.hh:846
kXR_unt16 requestid
Definition XProtocol.hh:157
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 655 of file XrdXrootdTransit.cc.

656{
659 const char *eMsg;
660 int rc;
661 bool aOK;
662
663// Invoke the result object (we initially assume this is the final result)
664//
665 runDone = true;
666 switch(rcode)
667 {case kXR_error:
668 rc = XRD_GETNUM(ioV[0].iov_base);
669 eMsg = (ioN < 2 ? "" : (const char *)ioV[1].iov_base);
670 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
671 aOK = respObj->Error(rInfo, rc, eMsg);
672 break;
673 case kXR_ok:
674 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
675 aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL, true)
676 : respObj->Done(rInfo));
677 break;
678 case kXR_oksofar:
679 aOK = respObj->Data(rInfo, ioV, ioN, ioL, false);
680 runDone = false;
681 break;
682 case kXR_redirect:
683 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
684 rc = XRD_GETNUM(ioV[0].iov_base);
685 aOK = respObj->Redir(rInfo,rc,(const char *)ioV[1].iov_base);
686 break;
687 case kXR_wait:
688 return Wait(rInfo, ioV, ioN, ioL);
689 break;
690 case kXR_waitresp:
691 runDone = false;
692 return WaitResp(rInfo, ioV, ioN, ioL);
693 break;
694 default: if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
695 aOK = respObj->Error(rInfo, kXR_ServerError,
696 "internal logic error");
697 break;
698 };
699
700// All done
701//
702 return (aOK ? 0 : -1);
703}
@ 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)
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(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), XrdXrootdResponse::Send(), 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 707 of file XrdXrootdTransit.cc.

708{
711 offset, dlen, fdnum);
712
713// Effect callback (this is always a final result)
714//
715 runDone = true;
716 return (respObj->File(sfInfo, dlen) ? 0 : -1);
717}
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 721 of file XrdXrootdTransit.cc.

722{
725 sfvec, sfvnum, dlen);
726
727// Effect callback (this is always a final result)
728//
729 runDone = true;
730 return (respObj->File(sfInfo, dlen) ? 0 : -1);
731}

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: