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 ()
XrdProtocol * Match (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
XrdXrootdProtocol * VerifyStream (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 XrdXrootdTransit * Alloc (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 Bridge * Login (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
XrdJob * NextJob
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 ()
bool RequestClose ()
int SetSF (kXR_char *fhandle, bool seton=false)
Static Protected Member Functions inherited from XrdXrootdProtocol
static bool CloseRequestCb (void *cbarg)
static unsigned int getSID ()
Protected Attributes inherited from XrdXrootdProtocol
bool ableTLS
char * AppName
XrdBuffer * argp
XrdSecProtocol * AuthProt
XrdSysSemaphore * boundRecycle
unsigned char CapVer
XrdSecEntity * Client
int clientPV
int clientRN
bool CloseRequested
int cumReadP
int cumReads
int cumReadV
int cumSegsV
int cumSegsW
int cumWrites
int cumWritV
char doTLS
XrdSysCondVar2 * endNote
XrdSecEntity Entity
XrdXrootdFileTable * FTab
struct XrdXrootdProtocol::GetDataCtl gdCtl
int halfBSize
int hcNext
int hcNow
int hcPrev
XrdXrootd::IOParms IO
bool isActive
bool isLinkWT
bool isNOP
bool isTLS
XrdLink * Link
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
XrdXrootdPgwCtl * pgwCtl
XrdXrootdPio * pioFirst
XrdXrootdPio * pioFree
XrdXrootdPio * pioLast
bool pmDone
XrdNetPMark::Handle * pmHandle
int PrepareCount
XrdSecProtect * Protect
short rdType
XrdXrootdReqID ReqID
ClientRequest Request
char reserved [3]
XrdXrootdResponse Response
int(XrdXrootdProtocol::* Resume )()
int(XrdXrootdProtocol::* ResumePio )()
XrdSysSemaphore * reTry
unsigned char rvSeq
char sigBuff [64]
bool sigHere
bool sigNeed
bool sigRead
SecurityRequest sigReq
ClientRequest sigReq2Ver
bool sigWarn
char Status
XrdXrootdProtocol * Stream [maxStreams]
XrdSysMutex streamMutex
long long totReadP
XrdSysMutex unbindMutex
XrdXrootdWVInfo * wvInfo
unsigned char wvSeq
Static Protected Attributes inherited from XrdXrootdProtocol
static XrdNetSocket * AdminSock = 0
static XrdBuffManager * BPool
static XrdSecService * CIA = 0
static bool CL_Redir = false
static XrdSecProtector * DHS = 0
static XrdSfsFileSystem * digFS = 0
static XrdSysError & eDest = 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 XrdXrootdJob * JobCKS = 0
static char * JobCKT = 0
static XrdOucTList * JobCKTLST = 0
static char JobLCL = 0
static time_t keepT = 86400
static bool LimitError = true
static XrdXrootdFileLock * Locker
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 XrdSfsFileSystem * osFS
static XrdNetPMark * PMark = 0
static int Port
static bool PrepareAlt = false
static int PrepareLimit = -1
static XrdOucReqID * PrepID = 0
static int readWait
static int redirIPHold = 8*60*60
static XrdXrootdRedirPI * RedirPI = 0
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 XrdScheduler * Sched
static XrdXrootdStats * SI
static RAtomic_int srvrAioOps = {0}
static char tlsCap = 0
static XrdTlsContext * tlsCtx = 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 waitCnd(0)
168 {}
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 169 of file XrdXrootdTransit.hh.

169{}

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

176{
177 char buff[128];
178
179// We do not allow disconnection while we are active
180//
181 if (runStatus.fetch_add(1, std::memory_order_acq_rel)) return false;
182
183// Reconnect original protocol to the link
184//
185 Link->setProtocol(realProt);
186
187// Now we need to recycle our xrootd part
188//
189 sprintf(buff, "%s disconnection", pName);
190 XrdXrootdProtocol::Recycle(Link, time(0)-cTime, buff);
191
192// Make sure that any pending wait jobs can exit
193//
194 {
195 XrdSysCondVarHelper clk(waitCnd);
196 waitPend = false;
197 runWait = 0;
198 waitCnd.Broadcast();
199 }
200
201// Now just free up our object.
202//
203 TranStack.Push(&TranLink);
204 return true;
205}
void Recycle(XrdLink *lp, int consec, const char *reason) override

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

235{
236 TranStack.Set(schedP, &XrdXrootdTrace, TRACE_MEM);
237 TranStack.Set(qMax, qTTL);
238}
#define TRACE_MEM
Definition XrdTrace.hh:38
XrdSysTrace XrdXrootdTrace

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

354{
355 int rc;
356
357// If we were interrupted in a reinvoke state, resume that state.
358//
359 if (reInvoke) rc = Process(Link);
360 else rc = 0;
361
362// Handle ending status
363//
364 if (rc >= 0) Link->Enable();
365 else if (rc != -EINPROGRESS) Link->Close();
366}
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 372 of file XrdXrootdTransit.cc.

373{
374 int rc;
375
376// This entry is serialized via link processing and data is now available.
377// One of the following will be returned.
378//
379// < 0 -> Stop getting requests,
380// -EINPROGRESS leave link disabled but otherwise all is well
381// -n Error, disable and close the link
382// = 0 -> OK, get next request, if allowed, o/w enable the link
383// > 0 -> Slow link, stop getting requests and enable the link
384//
385
386// Reflect data is present to the underlying protocol and if Run() has been
387// called we need to dispatch that request. This may be iterative.
388//
389do{rc = realProt->Process((reInvoke ? 0 : lp));
390 if (rc >= 0 && runStatus.load(std::memory_order_acquire))
391 {reInvoke = (rc == 0);
392 if (runError) rc = Fatal(rc);
393 else {runDone = false;
395 if (rc >= 0)
396 {if (runDone) runStatus.store(0, std::memory_order_release);
397 if (runWait)
398 {XrdSysCondVarHelper clk(waitCnd);
399 waitPend = false;
400 waitCnd.Broadcast();
401 return -EINPROGRESS;
402 }
403 if (!runDone) return rc;
404 }
405 }
406 } else reInvoke = false;
407 } while(rc >= 0 && reInvoke);
408
409// Make sure that we indicate that we are no longer active
410//
411 runStatus.store(0, std::memory_order_release);
412
413// All done
414//
415 return (rc ? rc : 1);
416}
int(XrdXrootdProtocol::* Resume)()
int Process(XrdLink *lp) override

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

423{
424
425// Set ourselves as active so we can't get more requests
426//
427 runStatus.fetch_add(1, std::memory_order_acq_rel);
428
429// If we were active then we will need to quiesce before dismantling ourselves.
430// Note that Recycle() can only be called if the link is enabled. So, this bit
431// of code is improbable but we check it anyway.
432//
433 if (runWait > 0) {
434 TRACEP(EMSG, "WARNING: Recycle is canceling wait job; the wait job might already be running during recycle.");
435 Sched->Cancel(&waitJob);
436 }
437
438// First we need to recycle the real protocol
439//
440 if (realProt) realProt->Recycle(lp, consec, reason);
441
442// Now we need to recycle our xrootd part
443//
444 XrdXrootdProtocol::Recycle(lp, consec, reason);
445
446// Release the argument buffer
447//
448 if (runArgs) {free(runArgs); runArgs = 0;}
449
450// Delete all pending requests
451//
453
454// Make sure that any pending wait jobs can exit
455//
456 {
457 XrdSysCondVarHelper clk(waitCnd);
458 waitPend = false;
459 runWait = 0;
460 waitCnd.Broadcast();
461 }
462
463// Now just free up our object.
464//
465 TranStack.Push(&TranLink);
466}
#define EMSG(x)
#define TRACEP(act, x)
static XrdScheduler * Sched
static void Clear(XrdXrootdTransit *trP)

References XrdXrootdTransPend::Clear(), EMSG, XrdXrootdProtocol::Recycle(), XrdXrootdProtocol::Sched, and TRACEP.

Here is the call graph for this function:

◆ Redrive()

void XrdXrootdTransit::Redrive ( )

Redrive a request after a wait.

Definition at line 472 of file XrdXrootdTransit.cc.

473{
474 static int eCode = htonl(kXR_NoMemory);
475 static char eText[] = "Insufficent memory to re-issue request";
476 static struct iovec ioV[] = {{(char *)&eCode,sizeof(eCode)},
477 {(char *)&eText,sizeof(eText)}};
478 int rc;
479
480// we ensure waitPend has been cleared. This is to allow the process or
481// redrive loops to have taken the correct action before we zero the
482// runWait value.
483//
484 {
485 XrdSysCondVarHelper clk(waitCnd);
486 while(waitPend) waitCnd.Wait();
487 }
488
489// Do some tracing
490//
491 TRACEP(REQ, "Bridge redrive runStatus="<<runStatus.load(std::memory_order_acquire)
492 <<" runError="<<runError
493 <<" runWait="<<runWait<<" runWTot="<<runWTot);
494
495// Update wait statistics
496//
497 runWTot += runWait;
498 runWait = 0;
499
500// While we are running asynchronously, there is no way that this object can
501// be deleted while a timer is outstanding as the link has been disabled. So,
502// we can reissue the request with little worry.
503//
504// This is a bit tricky here as a redriven request may result in a wait. If
505// this happens we cannot hand the result off to the real protocol until we
506// wait and successfully redrive. The wait handling occurs asynchronously
507// so all we need to do is honor it here.
508//
509 if (!runALen || RunCopy(runArgs, runALen)) {
510 do{runDone = false;
511 rc = Process2();
512 TRACEP(REQ, "Bridge redrive Process2 rc="<<rc
513 <<" runError="<<runError<<" runWait="<<runWait);
514 if (rc < 0) break;
515 if (runDone) runStatus.store(0, std::memory_order_release);
516 if (runWait || !runDone || !reInvoke) break;
517 rc = realProt->Process(NULL);
518 TRACEP(REQ, "Bridge redrive callback rc="<<rc
519 <<" runStatus="<<runStatus.load(std::memory_order_acquire));
520 if (rc < 0 || !runStatus.load(std::memory_order_acquire))
521 {reInvoke = false;
522 break;
523 }
524 reInvoke = (rc == 0);
525 if (runError) rc = Fatal(rc);
526 } while((rc >= 0) && !runError && !runWait);
527 }
528 else rc = Send(kXR_error, ioV, 2, 0);
529
530// Defer the request if need be
531//
532 if (rc >= 0 && runWait)
533 {XrdSysCondVarHelper clk(waitCnd);
534 waitPend = false;
535 waitCnd.Broadcast();
536 return;
537 }
538 runWTot = 0;
539
540// Indicate we are no longer active
541//
542 runStatus.store(0, std::memory_order_release);
543
544// If the link needs to be terminated, terminate the link. Otherwise, we can
545// enable the link for new requests at this point.
546//
547 if (rc < 0) Link->Close();
548 else Link->Enable();
549}
@ kXR_NoMemory
@ kXR_error
Definition XProtocol.hh:945
void Fatal(const char *op, const char *target)
Definition XrdCrc32c.cc:58
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.

References Fatal(), 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 557 of file XrdXrootdTransit.cc.

558{
559 static char rTab[kXR_truncate-kXR_auth+1];
560
561// Initialize the table
562//
563 memset(rTab, 0, sizeof(rTab));
564 rTab[KXR_INDEX(kXR_chmod)] = 1;
565 rTab[KXR_INDEX(kXR_close)] = 1;
566 rTab[KXR_INDEX(kXR_dirlist)] = 1;
567 rTab[KXR_INDEX(kXR_locate)] = 1;
568 rTab[KXR_INDEX(kXR_mkdir)] = 1;
569 rTab[KXR_INDEX(kXR_mv)] = 1;
570 rTab[KXR_INDEX(kXR_open)] = 1;
571 rTab[KXR_INDEX(kXR_prepare)] = 1;
572 rTab[KXR_INDEX(kXR_protocol)] = 1;
573 rTab[KXR_INDEX(kXR_query)] = 1;
574 rTab[KXR_INDEX(kXR_read)] = 2;
575 rTab[KXR_INDEX(kXR_readv)] = 2;
576 rTab[KXR_INDEX(kXR_rm)] = 1;
577 rTab[KXR_INDEX(kXR_rmdir)] = 1;
578 rTab[KXR_INDEX(kXR_set)] = 1;
579 rTab[KXR_INDEX(kXR_stat)] = 1;
580 rTab[KXR_INDEX(kXR_statx)] = 1;
581 rTab[KXR_INDEX(kXR_sync)] = 1;
582 rTab[KXR_INDEX(kXR_truncate)] = 1;
583 rTab[KXR_INDEX(kXR_write)] = 2;
584
585// Now return the address
586//
587 return rTab;
588}
@ kXR_read
Definition XProtocol.hh:126
@ kXR_open
Definition XProtocol.hh:123
@ kXR_readv
Definition XProtocol.hh:138
@ kXR_mkdir
Definition XProtocol.hh:121
@ kXR_sync
Definition XProtocol.hh:129
@ kXR_chmod
Definition XProtocol.hh:115
@ kXR_dirlist
Definition XProtocol.hh:117
@ kXR_rm
Definition XProtocol.hh:127
@ kXR_query
Definition XProtocol.hh:114
@ kXR_write
Definition XProtocol.hh:132
@ kXR_auth
Definition XProtocol.hh:113
@ kXR_set
Definition XProtocol.hh:131
@ kXR_rmdir
Definition XProtocol.hh:128
@ kXR_statx
Definition XProtocol.hh:135
@ kXR_truncate
Definition XProtocol.hh:141
@ kXR_protocol
Definition XProtocol.hh:119
@ kXR_mv
Definition XProtocol.hh:122
@ kXR_stat
Definition XProtocol.hh:130
@ kXR_locate
Definition XProtocol.hh:140
@ kXR_close
Definition XProtocol.hh:116
@ kXR_prepare
Definition XProtocol.hh:134
#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 621 of file XrdXrootdTransit.cc.

622{
623 int movLen;
624
625// We do not allow re-entry if we are curently processing a request.
626// It will be reset, as need, when a response is effected.
627//
628
629 if (runStatus.fetch_add(1, std::memory_order_acq_rel))
630 {TRACEP(REQ, "Bridge request failed due to re-entry");
631 return false;
632 }
633
634// Copy the request header
635//
636 memcpy((void *)&Request, (void *)xreqP, sizeof(Request));
637
638// Validate that we can actually handle this request
639//
640 Request.header.requestid = ntohs(Request.header.requestid);
641 if (Request.header.requestid & 0x8000
642 || Request.header.requestid > static_cast<kXR_unt16>(kXR_truncate)
643 || !reqTab[Request.header.requestid - kXR_auth])
644 {TRACEP(REQ, "Unsupported bridge request");
645 return Fail(kXR_Unsupported, "Unsupported bridge request");
646 }
647
648// Validate the data length
649//
650 Request.header.dlen = ntohl(Request.header.dlen);
651 if (Request.header.dlen < 0)
652 {TRACEP(REQ, "Invalid request data length");
653 return Fail(kXR_ArgInvalid, "Invalid request data length");
654 }
655
656// Copy the stream id and trace this request
657//
658 Response.Set(Request.header.streamid);
659 TRACEP(REQ, "Bridge req=" <<Request.header.requestid
660 <<" dlen=" <<Request.header.dlen <<" blen=" <<xdataL);
661
662// If this is a write request, we will need to do a lot more
663//
664 if (Request.header.requestid == kXR_write) return ReqWrite(xdataP, xdataL);
665
666// Obtain any needed buffer and handle any existing data arguments. Also, we
667// need to keep a shadow copy of the request arguments should we get a wait
668// and will need to re-issue the request (the server mangles the args).
669//
670 if (Request.header.dlen)
671 {movLen = (xdataL < Request.header.dlen ? xdataL : Request.header.dlen);
672 if (!RunCopy(xdataP, movLen)) return true;
673 if (!runArgs || movLen > runABsz)
674 {if (runArgs) free(runArgs);
675 if (!(runArgs = (char *)malloc(movLen)))
676 {TRACEP(REQ, "Failed to allocate memory");
677 return Fail(kXR_NoMemory, "Insufficient memory");
678 }
679 runABsz = movLen;
680 }
681 memcpy(runArgs, xdataP, movLen); runALen = movLen;
682 if ((myBlen = Request.header.dlen - movLen))
683 {myBuff = argp->buff + movLen;
685 return true;
686 }
687 } else runALen = 0;
688
689// If we have all the data, indicate request accepted.
690//
691 runError = 0;
692 Resume = 0;
693 return true;
694}
@ kXR_ArgInvalid
@ kXR_Unsupported
unsigned short kXR_unt16
Definition XPtypes.hh:67
XrdXrootdResponse Response

References XrdXrootdProtocol::argp, 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 723 of file XrdXrootdTransit.cc.

724{
725 XrdXrootd::Bridge::Context rInfo(Link, Request.header.streamid,
726 Request.header.requestid);
727 const char *eMsg;
728 int rc;
729 bool aOK;
730
731// Invoke the result object (we initially assume this is the final result)
732//
733 runDone = true;
734 switch(rcode)
735 {case kXR_error:
736 rc = XRD_GETNUM(ioV[0].iov_base);
737 eMsg = (ioN < 2 ? "" : (const char *)ioV[1].iov_base);
738 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
739 aOK = respObj->Error(rInfo, rc, eMsg);
740 break;
741 case kXR_ok:
742 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
743 aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL, true)
744 : respObj->Done(rInfo));
745 break;
746 case kXR_oksofar:
747 aOK = respObj->Data(rInfo, ioV, ioN, ioL, false);
748 runDone = false;
749 break;
750 case kXR_redirect:
751 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
752 rc = XRD_GETNUM(ioV[0].iov_base);
753 aOK = respObj->Redir(rInfo,rc,(const char *)ioV[1].iov_base);
754 break;
755 case kXR_wait:
756 return Wait(rInfo, ioV, ioN, ioL);
757 break;
758 case kXR_waitresp:
759 runDone = false;
760 return WaitResp(rInfo, ioV, ioN, ioL);
761 break;
762 default: if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
763 aOK = respObj->Error(rInfo, kXR_ServerError,
764 "internal logic error");
765 break;
766 };
767
768// All done
769//
770 return (aOK ? 0 : -1);
771}
@ kXR_ServerError
@ kXR_waitresp
Definition XProtocol.hh:948
@ kXR_redirect
Definition XProtocol.hh:946
@ kXR_oksofar
Definition XProtocol.hh:942
@ kXR_ok
Definition XProtocol.hh:941
@ kXR_wait
Definition XProtocol.hh:947
#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 775 of file XrdXrootdTransit.cc.

776{
777 XrdXrootdTransSend sfInfo(Link, Request.header.streamid,
778 Request.header.requestid,
779 offset, dlen, fdnum);
780
781// Effect callback (this is always a final result)
782//
783 runDone = true;
784 return (respObj->File(sfInfo, dlen) ? 0 : -1);
785}

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

◆ Send() [3/3]

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

Definition at line 789 of file XrdXrootdTransit.cc.

790{
791 XrdXrootdTransSend sfInfo(Link, Request.header.streamid,
792 Request.header.requestid,
793 sfvec, sfvnum, dlen);
794
795// Effect callback (this is always a final result)
796//
797 runDone = true;
798 return (respObj->File(sfInfo, dlen) ? 0 : -1);
799}

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