61 ntohl(*(static_cast<unsigned int *>(static_cast<void *>(x))))
70 XrdXrootdTransit::TranStack(
"TranStack",
71 "transit protocol anchor");
89 xp->
Init(rsltP, linkP, seceP, nameP, protP);
98 const struct iovec *ioV,
int ioN,
int ioL)
105 {
TRACE(REQ,
"Unable to find request for " <<lP->
ID <<
" sid=" <<*theSID);
111 return tP->
bridge->AttnCont(tP, rcode, ioV, ioN, ioL);
119 const struct iovec *ioV,
int ioN,
int ioL)
132 && (!ioN ||
XRD_GETNUM(ioV[0].iov_base) == 0))
139 rc =
Send(rcode, ioV, ioN, ioL);
143 if (rc >= 0 && !runWait)
172 if (rc)
return false;
176 Link->setProtocol(realProt);
180 sprintf(buff,
"%s disconnection", pName);
185 TranStack.Push(&TranLink);
193bool XrdXrootdTransit::Fail(
int ecode,
const char *etext)
204int XrdXrootdTransit::Fatal(
int rc)
206 XrdXrootd::Bridge::Context rInfo(
Link,
Request.header.streamid,
209 return (respObj->Error(rInfo, runError, runEText) ? rc : -1);
219 TranStack.Set(qMax, qTTL);
265 strncpy(uname, nameP,
sizeof(uname)-1);
266 uname[
sizeof(uname)-1] = 0;
317 who = (seceP && seceP->
name ? seceP->
name :
"nobody");
345 if (rc >= 0)
Link->Enable();
346 else if (rc != -EINPROGRESS)
Link->Close();
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;
377 {
if (runWait) rc = -EINPROGRESS;
378 if (!runDone)
return rc;
384 }
else reInvoke =
false;
385 }
while(rc >= 0 && reInvoke);
397 return (rc ? rc : 1);
417 if (runWait > 0)
Sched->Cancel(&waitJob);
421 if (realProt) realProt->Recycle(lp, consec, reason);
429 if (runArgs) {free(runArgs); runArgs = 0;}
437 TranStack.Push(&TranLink);
447 static char eText[] =
"Insufficent memory to re-issue request";
448 static struct iovec ioV[] = {{(
char *)&eCode,
sizeof(eCode)},
449 {(
char *)&eText,
sizeof(eText)}};
454 TRACEP(REQ,
"Bridge redrive runStatus="<<runStatus<<
" runError="<<runError
455 <<
" runWait="<<runWait<<
" runWTot="<<runWTot);
471 if (!runALen || RunCopy(runArgs, runALen)) {
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);
485 }
while((rc == 0) && !runError && !runWait);
491 if (rc >= 0 && runWait)
return;
505 if (rc < 0)
Link->Close();
513#define KXR_INDEX(x) x-kXR_auth
521 memset(rTab, 0,
sizeof(rTab));
552bool XrdXrootdTransit::ReqWrite(
char *xdataP,
int xdataL)
562 {
Resume = 0; wBuff = xdataP; wBLen = xdataL;
590 {
TRACEP(REQ,
"Bridge request failed due to re-entry");
601 if (
Request.header.requestid & 0x8000
604 {
TRACEP(REQ,
"Unsupported bridge request");
612 {
TRACEP(REQ,
"Invalid request data length");
620 <<
" dlen=" <<
Request.header.dlen <<
" blen=" <<xdataL);
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");
641 memcpy(runArgs, xdataP, movLen); runALen = movLen;
660bool XrdXrootdTransit::RunCopy(
char *buffP,
int buffL)
668 {Fail(
kXR_ArgTooLong,
"Request argument too long");
return false;}
674 memcpy(
argp->buff, buffP, buffL);
675 argp->buff[buffL] = 0;
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);
702 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
703 aOK = (ioN ? respObj->Data(rInfo, ioV, ioN, ioL,
true)
704 : respObj->Done(rInfo));
707 aOK = respObj->Data(rInfo, ioV, ioN, ioL,
false);
711 if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
713 aOK = respObj->Redir(rInfo,rc,(
const char *)ioV[1].iov_base);
716 return Wait(rInfo, ioV, ioN, ioL);
720 return WaitResp(rInfo, ioV, ioN, ioL);
722 default:
if (wBuff) respObj->Free(rInfo, wBuff, wBLen);
724 "internal logic error");
730 return (aOK ? 0 : -1);
739 offset, dlen, fdnum);
744 return (respObj->File(sfInfo, dlen) ? 0 : -1);
753 sfvec, sfvnum, dlen);
758 return (respObj->File(sfInfo, dlen) ? 0 : -1);
766 const struct iovec *ioV,
int ioN,
int ioL)
773 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
778 {
int wtime = runWait;
780 return (respObj->
Wait(rInfo, wtime,
eMsg) ? 0 : -1);
785 if (runWTot >= runWMax)
793 if (runWait > runWMax) runWait = runWMax;
797 if (runWCall && !(respObj->Wait(rInfo, runWait,
eMsg)))
return -1;
801 TRACEP(REQ,
"Bridge delaying request " <<runWait <<
" sec (" <<
eMsg <<
")");
802 Sched->Schedule((
XrdJob *)&waitJob, time(0)+runWait);
811 const struct iovec *ioV,
int ioN,
int ioL)
813 XrdXrootdTransPend *trP;
820 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
821 TRACEP(REQ,
"Bridge waiting for resp; sid=" <<rInfo.
sID.num
822 <<
" wt=" <<wTime <<
" (" <<
eMsg <<
")");
831 trP =
new XrdXrootdTransPend(
Link,
this, &
Request);
struct ClientRequestHdr header
struct ClientLoginRequest login
XrdOucTrace * XrdXrootdTrace
void Release(XrdBuffer *bp)
XrdBuffer * Obtain(int bsz)
friend class XrdScheduler
XrdJob(const char *desc="")
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
void setID(const char *userid, int procid)
XrdNetAddrInfo * AddrInfo()
char * ID
Pointer to the client's link identity.
void armBridge()
Mark this link as an in-memory communications bridge (internal use only).
void setProtName(const char *name)
const char * Host() const
unsigned int Inst() const
bool isIPType(IPType ipType) const
static void Sanitize(char *instr, char subc='_')
void Schedule(XrdJob *jp)
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
char * name
Entity's name.
char * host
Entity's host name dnr dependent.
static XrdXrootdStats * SI
static XrdSysError & eDest
static unsigned int getSID()
XrdXrootdMonitor::User Monitor
int(XrdXrootdProtocol::* Resume)()
static XrdScheduler * Sched
int Process(XrdLink *lp) override
void Recycle(XrdLink *lp, int consec, const char *reason) override
XrdXrootdResponse Response
static XrdBuffManager * BPool
static XrdSfsFileSystem * osFS
static XrdXrootdTransPend * Remove(XrdLink *lP, short sid)
union XrdXrootdTransPend::@371012140333040222300212162025004307132302363251 Pend
XrdXrootdTransit * bridge
static void Clear(XrdXrootdTransit *trP)
bool Run(const char *xreqP, char *xdataP=0, int xdataL=0)
Inject an xrootd request into the protocol stack.
static const char * ReqTable()
Initialize the valid request table.
void Redrive()
Redrive a request after a wait.
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.
void Recycle(XrdLink *lp, int consec, const char *reason)
Handle link shutdown.
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
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)
XrdXrootdTransit()
Constructor & Destructor.
void Proceed()
Resume processing after a waitresp completion.
bool Disc()
Handle dismantlement.
int Process(XrdLink *lp)
Handle link activation (replaces parent activation).
union XrdXrootd::Bridge::Context::@216053020250347016153077031152206173164054152024 sID
associated request stream ID
virtual bool Wait(Bridge::Context &info, int wtime, const char *wtext)
static const int uIPv4
ucap: Supports read redirects