Loading...
Searching...
No Matches
XrdXrootdTransit.hh
Go to the documentation of this file.
#ifndef __XRDXROOTDTRANSIT_HH_
#define __XRDXROOTDTRANSIT_HH_
/******************************************************************************/
/* */
/* X r d X r o o t d T r a n s i t . h h */
/* */
/* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <sys/types.h>
#include "XrdSys/XrdSysRAtomic.hh"
#include "XrdSys/XrdSysPthread.hh"
#include "XrdXrootd/XrdXrootdBridge.hh"
#include "XrdXrootd/XrdXrootdProtocol.hh"
#include "Xrd/XrdObject.hh"
#include <atomic>
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
struct XrdOucSFVec;
class XrdScheduler;
class XrdXrootdTransPend;
struct iovec;
class XrdXrootdTransit : public XrdXrootd::Bridge, public XrdXrootdProtocol
{
public:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static
XrdXrootdTransit *Alloc(XrdXrootd::Bridge::Result *respP,
XrdLink *linkP,
XrdSecEntity *seceP,
const char *nameP,
const char *protP
);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static int Attn(XrdLink *lP, short *theSID, int rcode,
const struct iovec *ioVec, int ioNum, int ioLen);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool Disc();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static void Init(XrdScheduler *schedP, int qMax, int qTTL);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void Proceed();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int Process(XrdLink *lp); // XrdProtocol override
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void Recycle(XrdLink *lp, int consec, const char *reason);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void Redrive();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
static
const char *ReqTable();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
bool Run(const char *xreqP,
char *xdataP=0,
int xdataL=0
);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int Send(long long offset, int dlen, int fdnum);
int Send(XrdOucSFVec *sfvec, int sfvnum, int dlen);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int setSF(kXR_char *fhandle, bool seton=false)
{return SetSF(fhandle, seton);}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void SetWait(int wtime, bool notify=false)
{runWMax = wtime; runWCall = notify;}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
XrdXrootdTransit() : TranLink(this),
respJob(this, &XrdXrootdTransit::Proceed,
"Transit proceed"),
waitJob(this, &XrdXrootdTransit::Redrive,
"Transit redrive")
{}
virtual ~XrdXrootdTransit() {}
private:
int AttnCont(XrdXrootdTransPend *tP, int rcode,
const struct iovec *ioV, int ioN, int ioL);
bool Fail(int ecode, const char *etext);
int Fatal(int rc);
void Init(Result *rsltP, XrdLink *linkP, XrdSecEntity *seceP,
const char *nameP, const char *protP
);
bool ReqWrite(char *xdataP, int xdataL);
bool RunCopy(char *buffP, int buffL);
int Wait(XrdXrootd::Bridge::Context &rInfo,
const struct iovec *ioV, int ioN, int ioL);
int WaitResp(XrdXrootd::Bridge::Context &rInfo,
const struct iovec *ioV, int ioN, int ioL);
class SchedReq : public XrdJob
{public:
typedef void (XrdXrootdTransit::*callbackFP)();
void DoIt() {(spanP->*cbFunc)();}
SchedReq(XrdXrootdTransit *tP, callbackFP cbP, const char *why)
: XrdJob(why), spanP(tP), cbFunc(cbP) {}
~SchedReq() {}
private:
XrdXrootdTransit *spanP;
callbackFP cbFunc;
};
static XrdObjectQ<XrdXrootdTransit> TranStack;
XrdObject<XrdXrootdTransit> TranLink;
SchedReq respJob;
SchedReq waitJob;
XrdSysMutex runMutex;
static const char *reqTab;
XrdProtocol *realProt;
XrdXrootd::Bridge::Result *respObj;
const char *runEText;
char *runArgs;
int runALen;
int runABsz;
int runError;
// Set to 1 if there is a xroot request to the bridge; 0 otherwise. Used to prevent multiple
// active requests from going on at once for a given link - or for disconnecting while a
// request is ongoing.
std::atomic<int> runStatus;
RAtomic_int runWait;
int runWTot;
int runWMax;
bool runDone;
bool reInvoke;
bool runWCall;
int wBLen;
char *wBuff;
const char *pName;
time_t cTime;
};
#endif
kXR_char
unsigned char kXR_char
Definition XPtypes.hh:65
Fatal
void Fatal(const char *op, const char *target)
Definition XrdCrc32c.cc:58
XrdObject.hh
XrdSysPthread.hh
XrdSysRAtomic.hh
RAtomic_int
XrdSys::RAtomic< int > RAtomic_int
Definition XrdSysRAtomic.hh:325
XrdXrootdBridge.hh
XrdXrootdProtocol.hh
XrdJob
Definition XrdJob.hh:43
XrdJob::XrdScheduler
friend class XrdScheduler
Definition XrdJob.hh:44
XrdJob::XrdJob
XrdJob(const char *desc="")
Definition XrdJob.hh:51
XrdJob::DoIt
virtual void DoIt()=0
XrdLink
Definition XrdLink.hh:52
XrdProtocol::XrdProtocol
XrdProtocol(const char *jname)
Definition XrdProtocol.hh:156
XrdScheduler
Definition XrdScheduler.hh:47
XrdSecEntity
Definition XrdSecEntity.hh:65
XrdXrootdProtocol::SetSF
int SetSF(kXR_char *fhandle, bool seton=false)
Definition XrdXrootdXeq.cc:4314
XrdXrootdProtocol::XrdXrootdProtocol
XrdXrootdProtocol()
Definition XrdXrootdProtocol.cc:259
XrdXrootdTransPend
Definition XrdXrootdTransPend.hh:43
XrdXrootdTransit
Definition XrdXrootdTransit.hh:56
XrdXrootdTransit::Run
bool Run(const char *xreqP, char *xdataP=0, int xdataL=0)
Inject an xrootd request into the protocol stack.
Definition XrdXrootdTransit.cc:558
XrdXrootdTransit::ReqTable
static const char * ReqTable()
Initialize the valid request table.
Definition XrdXrootdTransit.cc:494
XrdXrootdTransit::Redrive
void Redrive()
Redrive a request after a wait.
Definition XrdXrootdTransit.cc:431
XrdXrootdTransit::Send
int Send(int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle request data response.
Definition XrdXrootdTransit.cc:660
XrdXrootdTransit::Recycle
void Recycle(XrdLink *lp, int consec, const char *reason)
Handle link shutdown.
Definition XrdXrootdTransit.cc:390
XrdXrootdTransit::Init
static void Init(XrdScheduler *schedP, int qMax, int qTTL)
Perform one-time initialization.
Definition XrdXrootdTransit.cc:208
XrdXrootdTransit::Alloc
static XrdXrootdTransit * Alloc(XrdXrootd::Bridge::Result *respP, XrdLink *linkP, XrdSecEntity *seceP, const char *nameP, const char *protP)
Get a new transit object.
Definition XrdXrootdTransit.cc:77
XrdXrootdTransit::setSF
int setSF(kXR_char *fhandle, bool seton=false)
Set sendfile() enablement.
Definition XrdXrootdTransit.hh:148
XrdXrootdTransit::Attn
static int Attn(XrdLink *lP, short *theSID, int rcode, const struct iovec *ioVec, int ioNum, int ioLen)
Handle attention response (i.e. async response).
Definition XrdXrootdTransit.cc:97
XrdXrootdTransit::~XrdXrootdTransit
virtual ~XrdXrootdTransit()
Definition XrdXrootdTransit.hh:168
XrdXrootdTransit::SetWait
void SetWait(int wtime, bool notify=false)
Set maximum wait time.
Definition XrdXrootdTransit.hh:155
XrdXrootdTransit::XrdXrootdTransit
XrdXrootdTransit()
Constructor & Destructor.
Definition XrdXrootdTransit.hh:162
XrdXrootdTransit::Proceed
void Proceed()
Resume processing after a waitresp completion.
Definition XrdXrootdTransit.cc:326
XrdXrootdTransit::Disc
bool Disc()
Handle dismantlement.
Definition XrdXrootdTransit.cc:158
XrdXrootdTransit::Process
int Process(XrdLink *lp)
Handle link activation (replaces parent activation).
Definition XrdXrootdTransit.cc:345
XrdXrootd::Bridge::Context
Definition XrdXrootdBridge.hh:226
XrdXrootd::Bridge::Result
Definition XrdXrootdBridge.hh:294
XrdXrootd::Bridge
Definition XrdXrootdBridge.hh:62
XrdOucSFVec
Definition XrdOucSFVec.hh:43