Skip to content

Commit

Permalink
[XrdSsi] Additional cleanup and enhancements.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Feb 11, 2017
1 parent ab2d315 commit 38c643a
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 82 deletions.
3 changes: 2 additions & 1 deletion src/XrdSsi/XrdSsiClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ void XrdSsiClientProvider::SetCBThreads(int cbNum, int ntNum)
// Validate thread number
//
if (cbNum > 1)
{if (cbNum < 32767) cbNum = 32767; // Max short value
{if (cbNum > 32767) cbNum = 32767; // Max short value
if (ntNum < 1) ntNum = cbNum*10/100;
if (ntNum < 3) ntNum = 0;
else if (ntNum > 100) ntNum = 100;
clMutex.Lock();
maxTCB = static_cast<short>(cbNum);
maxCLW = static_cast<short>(ntNum);
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiEntity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
class XrdSsiEntity
{
public:
char prot[XrdSsiPROTOIDSIZE]; //!< Protocol used
char prot[XrdSsiPROTOIDSIZE]; //!< Protocol used
const char *name; //!< Entity's name
const char *host; //!< Entity's host name or address
const char *vorg; //!< Entity's virtual organization
Expand Down
15 changes: 5 additions & 10 deletions src/XrdSsi/XrdSsiFileResource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,26 @@
/* I n i t */
/******************************************************************************/

void XrdSsiFileResource::Init(const char *path, XrdOucEnv &envX, int atype)
void XrdSsiFileResource::Init(const char *path, XrdOucEnv &envX, bool aDNS)
{
const XrdSecEntity *entP = envX.secEnv();
const char *rVal;
int n;

// Always supply the trace identity
//
mySec.tident = (entP ? entP->tident : "ssi");

// Construct the security information
//
if (atype && entP)
if (entP)
{strncpy(mySec.prot, entP->prot, XrdSsiPROTOIDSIZE);
mySec.name = entP->name;
mySec.host = (atype <= 1 ? entP->host
: entP->addrInfo->Name(entP->host));
mySec.host = (!aDNS ? entP->host : entP->addrInfo->Name(entP->host));
mySec.role = entP->vorg;
mySec.role = entP->role;
mySec.grps = entP->grps;
mySec.endorsements = entP->endorsements;
mySec.creds = entP->creds;
mySec.credslen = entP->credslen;
client = &mySec;
}
} else mySec.tident = "ssi";
client = &mySec;

// Fill out the resource name and user
//
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiFileResource.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class XrdSsiFileResource : public XrdSsiResource
{
public:

void Init(const char *path, XrdOucEnv &envP, int atype);
void Init(const char *path, XrdOucEnv &envP, bool aDNS);

XrdSsiFileResource() : XrdSsiResource(std::string(""))
{memset(&mySec, 0, sizeof(mySec));}
Expand Down
4 changes: 2 additions & 2 deletions src/XrdSsi/XrdSsiFileSess.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int XrdSsiFileSess::freeNew = 0;
int XrdSsiFileSess::freeMax = 100;
int XrdSsiFileSess::freeAbs = 200;

int XrdSsiFileSess::authXQ = 0;
bool XrdSsiFileSess::authDNS = false;

int XrdSsiFileSess::maxRSZ = 0;

Expand Down Expand Up @@ -391,7 +391,7 @@ int XrdSsiFileSess::open(const char *path, // In

// Setup the file resource object
//
fileResource.Init(path, theEnv, authXQ);
fileResource.Init(path, theEnv, authDNS);

// Notify the provider that we will be executing a request
//
Expand Down
4 changes: 2 additions & 2 deletions src/XrdSsi/XrdSsiFileSess.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ XrdSsiFileResource &Resource() {return fileResource;}
XrdSfsFileOffset offset,
XrdSfsXferSize size);

static void SetAuth(int axq) {authXQ = axq;}
static void SetAuthDNS() {authDNS = true;}

static void SetMaxSz(int mSz) {maxRSZ = mSz;}

Expand Down Expand Up @@ -113,7 +113,7 @@ static int freeMax;
static int freeAbs;

static int maxRSZ;
static int authXQ;
static bool authDNS;

XrdSsiFileResource fileResource;
char *tident;
Expand Down
5 changes: 4 additions & 1 deletion src/XrdSsi/XrdSsiProvider.hh
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ virtual rStat QueryResource(const char *rName,
//!
//! @param cbNum The maximum number of threads to be used for callbacks and
//! sets the maximum number of active callbacks (default 300).
//! The maximum value is 32767. Note that the nproc ulimit is
//! final arbiter of the actual number of threads to use.
//! @param ntNum The maximum number of threads to be used to handle network
//! traffic. The minimum is 3, the default is 10% of cbNum.
//! traffic. The minimum is 3, the default is 10% of cbNum but
//! no more than 100.
//-----------------------------------------------------------------------------

virtual void SetCBThreads(int cbNum, int ntNum=0) {(void)cbNum; (void)ntNum;}
Expand Down
65 changes: 38 additions & 27 deletions src/XrdSsi/XrdSsiRequest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ enum PRD_Xeq {PRD_Normal = 0, PRD_Hold = 1, PRD_HoldLcl = 2};
virtual PRD_Xeq ProcessResponseData(const XrdSsiErrInfo &eInfo, char *buff,
int blen, bool last) {return PRD_Normal;}


//-----------------------------------------------------------------------------
//! Release the request buffer of the request bound to this object. This method
//! duplicates the protected method of the same name in XrdSsiRequest and exists
//! here for calling safety and consistency relative to the responder.
//-----------------------------------------------------------------------------

inline void ReleaseRequestBuffer() {XrdSsiMutexMon(rrMutex);
RelRequestBuffer();
}

//-----------------------------------------------------------------------------
//! Restart a ProcessResponseData() call for a request that was previosly held
//! (see return enums on ProcessResponseData method). This is a client-side
Expand Down Expand Up @@ -271,33 +282,6 @@ struct RDR_Info{int rCount; //!< Number restarted

static RDR_Info RestartDataResponse(RDR_How rhow, const char *reqid=0);

//-----------------------------------------------------------------------------
//! @brief Set the detached request time to live value.
//!
//! By deafult, rqeuests are executed in the foreground (i.e. during its
//! execution, if the TCP connection drops, the request is automatically
//! cancelled. When a non-zero time to live is set, the request is executed in
//! the background (i.e. detached) and no persistent TCP connection is required.
//! You must use the XrdSsiService::Attach() method to foreground such a
//! request within the number of seconds specified for dttl or the request is
//! automatically cancelled. The value must be set before passing the request
//! to XrdSsiService::ProcessRequest(). Once the request is started, a request
//! handle is returned which can be passed to XrdSsiService::Attach().
//!
//! @param detttl The detach time to live value.
//-----------------------------------------------------------------------------

inline void SetDetachTTL(uint32_t dttl) {detTTL = dttl;}

//-----------------------------------------------------------------------------
//! Set timeout for initiating the request. If a non-default value is desired,
//! it must be set prior to calling XrdSsiService::ProcessRequest().
//!
//! @param tmo The timeout value.
//-----------------------------------------------------------------------------

void SetTimeOut(uint16_t tmo) {tOut = tmo;}

//-----------------------------------------------------------------------------
//! Constructor
//!
Expand Down Expand Up @@ -341,6 +325,33 @@ virtual void BindDone() {}

virtual void RelRequestBuffer() {}

//-----------------------------------------------------------------------------
//! @brief Set the detached request time to live value.
//!
//! By deafult, rqeuests are executed in the foreground (i.e. during its
//! execution, if the TCP connection drops, the request is automatically
//! cancelled. When a non-zero time to live is set, the request is executed in
//! the background (i.e. detached) and no persistent TCP connection is required.
//! You must use the XrdSsiService::Attach() method to foreground such a
//! request within the number of seconds specified for dttl or the request is
//! automatically cancelled. The value must be set before passing the request
//! to XrdSsiService::ProcessRequest(). Once the request is started, a request
//! handle is returned which can be passed to XrdSsiService::Attach().
//!
//! @param detttl The detach time to live value.
//-----------------------------------------------------------------------------

inline void SetDetachTTL(uint32_t dttl) {detTTL = dttl;}

//-----------------------------------------------------------------------------
//! Set timeout for initiating the request. If a non-default value is desired,
//! it must be set prior to calling XrdSsiService::ProcessRequest().
//!
//! @param tmo The timeout value.
//-----------------------------------------------------------------------------

void SetTimeOut(uint16_t tmo) {tOut = tmo;}

//-----------------------------------------------------------------------------
//! Destructor. This object can only be deleted by the object creator. Once the
//! object is passed to XrdSsiService::ProcessRequest() it may only be deleted
Expand Down
18 changes: 8 additions & 10 deletions src/XrdSsi/XrdSsiResource.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ enum Affinity {Default, //!< Use configured affinity
};
Affinity affinity;//!< Resource affinity

static const
uint16_t reusable= 0x0001; //!< Make this resource is reusable

uint16_t rOpts; //!< Resource options (see above)
uint16_t reUse; //!< Number of minutes resource may be reused
uint32_t rOpts; //!< Resource options. One or more of he following:
static
const uint32_t Reusable;//!> Resource context may be cached and reused
static
const uint32_t Discard; //!> Discard cached resource if it exists

//-----------------------------------------------------------------------------
//! Constructor
Expand All @@ -86,20 +86,18 @@ uint16_t reUse; //!< Number of minutes resource may be reused
//!
//! @param raff resource affinity (see Affinity enum).
//!
//! @param ropts resource handling options (see enum).
//!
//! @param reUse number of times the resource may be reused.
//! @param ropts resource handling options (see individual options)
//-----------------------------------------------------------------------------

XrdSsiResource(std::string rname,
std::string havoid="",
std::string ruser="",
std::string rinfo="",
uint16_t ropts=0,
uint32_t ropts=0,
Affinity raff=Default
) : rName(rname), rUser(ruser), rInfo(rinfo),
hAvoid(havoid), client(0), affinity(raff),
rOpts(ropts), reUse(0) {}
rOpts(ropts) {}

//-----------------------------------------------------------------------------
//! Destructor
Expand Down
19 changes: 11 additions & 8 deletions src/XrdSsi/XrdSsiRespInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,28 @@
class XrdSsiStream;

struct XrdSsiRespInfo
{union {const char *buff; //!< ->buffer when rType == isData;
const char *eMsg; //!< ->msg text when rType == isError;
long long fsize; //!< ->file size when rType == isFile;
XrdSsiStream *strmP; //!< ->SsiStream when rType == isStream;
{union {const char *buff; //!< ->buffer when rType == isData
//!< ->buffer when rType == isHandle
const char *eMsg; //!< ->msg text when rType == isError
long long fsize; //!< ->file size when rType == isFile
XrdSsiStream *strmP; //!< ->SsiStream when rType == isStream
};
union { int blen; //!< buffer len When rType == isData;
int eNum; //!< errno When rType == isError;
int fdnum; //!< filedesc When rType == isFile;
union { int blen; //!< buffer len When rType == isData
//!< buffer len When rType == isHandle
int eNum; //!< errno When rType == isError
int fdnum; //!< filedesc When rType == isFile
};
int mdlen; //!< Metadata length
const char *mdata; //!< -> Metadata about response.

enum Resp_t {isNone = 0, isData, isError, isFile, isStream};
enum Resp_t {isNone = 0, isData, isError, isFile, isStream, isHandle};
Resp_t rType;

inline void Init() {fsize=0; blen=0; mdlen=0; mdata=0; rType=isNone;}

const char *State() const {if (rType == isData ) return "isData";
if (rType == isError ) return "isError";
if (rType == isHandle) return "isHandle";
if (rType == isFile ) return "isFile";
if (rType == isStream) return "isStream";
if (rType == isNone ) return "isNone";
Expand Down
17 changes: 14 additions & 3 deletions src/XrdSsi/XrdSsiService.hh
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,29 @@ static const int SsiVersion = 0x00020000;
//! provided. Server-side Attach() calls are always passed the original request
//! object reference so that it can pair up the request with the attach.
//!
//! @param handle The handle provided to the XrdSsiRequest::ProcessResponse()
//! callback method via isHandle response type. This is always
//! an empty string on server-side calls.
//!
//! @param reqRef Reference to the request object that is to attach to the
//! backgrounded request. It need not be the original request
//! object (client-side) but it always is the original request
//! object server-side.
//!
//! @param handle The handle provided to the XrdSsiRequest::ProcessResponse()
//! callback method via isHandle message type.
//! @param resP A pointer to the resource object describing the request
//! resources. This is meaningless for client calls and should
//! not be specified. For server-side calls, it can be used to
//! reauthorize the request since the client performing the
//! attach may be different fom the client that actually
//! started the request.
//!
//! @return All results are returned via the request object callback methods.
//-----------------------------------------------------------------------------

virtual void Attach(XrdSsiRequest &reqRef, std::string handle) {}
virtual void Attach(std::string handle,
XrdSsiRequest &reqRef,
XrdSsiResource *resP=0
) {}

//-----------------------------------------------------------------------------
//! @brief Prepare for processing subsequent resource request.
Expand Down
Loading

0 comments on commit 38c643a

Please sign in to comment.