58 #define TRACELINK Link
60 #define XRD_GETNUM(x)\
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;
180 sprintf(buff,
"%s disconnection", pName);
185 TranStack.
Push(&TranLink);
193 bool XrdXrootdTransit::Fail(
int ecode,
const char *etext)
204 int XrdXrootdTransit::Fatal(
int rc)
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");
346 else if (rc != -EINPROGRESS)
Link->
Close();
370 do{rc = realProt->
Process((reInvoke ? 0 : lp));
371 if (rc >= 0 && runStatus)
372 {reInvoke = (rc == 0);
373 if (runError) rc = Fatal(rc);
374 else {runDone =
false;
377 {
if (runWait) rc = -EINPROGRESS;
378 if (!runDone)
return rc;
384 }
else reInvoke =
false;
385 }
while(rc >= 0 && reInvoke);
397 return (rc ? rc : 1);
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)}};
461 if (!runALen || RunCopy(runArgs, runALen)) {
471 }
while((rc == 0) && !runError && !runWait);
477 if (rc >= 0 && runWait)
return;
499 #define KXR_INDEX(x) x-kXR_auth
507 memset(rTab, 0,
sizeof(rTab));
538 bool XrdXrootdTransit::ReqWrite(
char *xdataP,
int xdataL)
548 {
Resume = 0; wBuff = xdataP; wBLen = xdataL;
576 {
TRACEP(REQ,
"Bridge request failed due to re-entry");
590 {
TRACEP(REQ,
"Unsupported bridge request");
598 {
TRACEP(REQ,
"Invalid request data length");
618 if (!RunCopy(xdataP, movLen))
return true;
619 if (!runArgs || movLen > runABsz)
620 {
if (runArgs) free(runArgs);
621 if (!(runArgs = (
char *)malloc(movLen)))
622 {
TRACEP(REQ,
"Failed to allocate memory");
627 memcpy(runArgs, xdataP, movLen); runALen = movLen;
646 bool XrdXrootdTransit::RunCopy(
char *buffP,
int buffL)
654 {Fail(
kXR_ArgTooLong,
"Request argument too long");
return false;}
683 eMsg = (ioN < 2 ?
"" : (
const char *)ioV[1].iov_base);
684 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
688 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
689 aOK = (ioN ? respObj->
Data(rInfo, ioV, ioN, ioL,
true)
690 : respObj->
Done(rInfo));
693 aOK = respObj->
Data(rInfo, ioV, ioN, ioL,
false);
697 if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
699 aOK = respObj->
Redir(rInfo,rc,(
const char *)ioV[1].iov_base);
702 return Wait(rInfo, ioV, ioN, ioL);
706 return WaitResp(rInfo, ioV, ioN, ioL);
708 default:
if (wBuff) respObj->
Free(rInfo, wBuff, wBLen);
710 "internal logic error");
716 return (aOK ? 0 : -1);
725 offset, dlen, fdnum);
730 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
739 sfvec, sfvnum, dlen);
744 return (respObj->
File(sfInfo, dlen) ? 0 : -1);
752 const struct iovec *ioV,
int ioN,
int ioL)
759 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
764 {
int wtime = runWait;
766 return (respObj->
Wait(rInfo, wtime,
eMsg) ? 0 : -1);
771 if (runWTot >= runWMax)
779 if (runWait > runWMax) runWait = runWMax;
783 if (runWCall && !(respObj->
Wait(rInfo, runWait,
eMsg)))
return -1;
787 TRACEP(REQ,
"Bridge delaying request " <<runWait <<
" sec (" <<
eMsg <<
")");
797 const struct iovec *ioV,
int ioN,
int ioL)
806 eMsg = (ioN < 2 ?
"reason unknown" : (
const char *)ioV[1].iov_base);
807 TRACEP(REQ,
"Bridge waiting for resp; sid=" <<rInfo.
sID.num
808 <<
" wt=" <<wTime <<
" (" <<
eMsg <<
")");
struct ClientRequestHdr header
struct ClientLoginRequest login
XrdSysTrace XrdXrootdTrace
void Release(XrdBuffer *bp)
XrdBuffer * Obtain(int bsz)
XrdProtocol * setProtocol(XrdProtocol *pp, bool runit=false, bool push=false)
const char * Host() const
int Close(bool defer=false)
void setID(const char *userid, int procid)
void Enable()
Enable the link to field interrupts.
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)
unsigned int Inst() const
bool isIPType(IPType ipType) const
void Set(int inQMax, time_t agemax=1800)
void Push(XrdObject< T > *Node)
static void Sanitize(char *instr, char subc='_')
virtual void Recycle(XrdLink *lp=0, int consec=0, const char *reason=0)=0
virtual int Process(XrdLink *lp)=0
void Schedule(XrdJob *jp)
const char * pident
Trace identifier (originator)
XrdNetAddrInfo * addrInfo
Entity's connection details.
const char * tident
Trace identifier always preset.
char prot[XrdSecPROTOIDSIZE]
Auth protocol used (e.g. krb5)
char * name
Entity's name.
unsigned int ueid
Unique ID of entity instance.
char * host
Entity's host name dnr dependent.
virtual void Connect(const XrdSecEntity *client=0)
void Log(int mask, const char *esfx, const char *text1, const char *text2=0, const char *text3=0)
void Register(const char *Uname, const char *Hname, const char *Pname, unsigned int xSID=0)
void Report(const char *Info)
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
void setID(unsigned long long id)
static XrdXrootdTransPend * Remove(XrdLink *lP, short sid)
union XrdXrootdTransPend::@189 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::@162 sID
associated request stream ID
virtual int File(Bridge::Context &info, int dlen)=0
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 bool Wait(Bridge::Context &info, int wtime, const char *wtext)
virtual void Free(Bridge::Context &info, char *buffP, int buffL)
static const int uIPv4
ucap: Supports read redirects