Skip to content

Commit

Permalink
[XrdSsi] Additional conformance changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Feb 7, 2017
1 parent 7583163 commit ab2d315
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/XrdSsi.cmake
Expand Up @@ -34,7 +34,7 @@ XrdSsi/XrdSsiRequest.cc XrdSsi/XrdSsiRequest.hh
XrdSsi/XrdSsiResource.hh
XrdSsi/XrdSsiScale.hh
XrdSsi/XrdSsiServReal.cc XrdSsi/XrdSsiServReal.hh
XrdSsi/XrdSsiService.hh
XrdSsi/XrdSsiService.cc XrdSsi/XrdSsiService.hh
XrdSsi/XrdSsiSessReal.cc XrdSsi/XrdSsiSessReal.hh
XrdSsi/XrdSsiStream.hh
XrdSsi/XrdSsiTaskReal.cc XrdSsi/XrdSsiTaskReal.hh
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiAlert.cc
Expand Up @@ -98,7 +98,7 @@ void XrdSsiAlert::Recycle()

// Issue callback to release the message if we have one
//
if (theMsg) theMsg->Recycle();
if (theMsg) theMsg->RecycleMsg();

// Place object on the queue unless we have too many
//
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiFileReq.cc
Expand Up @@ -139,7 +139,7 @@ void XrdSsiFileReq::Alert(XrdSsiRespInfoMsg &aMsg)
//
if (msgLen <= 0 || rP->rType != XrdSsiRespInfo::isNone || isEnding)
{frqMutex.UnLock();
aMsg.Recycle();
aMsg.RecycleMsg();
return;
}

Expand Down
4 changes: 3 additions & 1 deletion src/XrdSsi/XrdSsiFileSess.cc
Expand Up @@ -52,6 +52,7 @@
#include "XrdSsi/XrdSsiEntity.hh"
#include "XrdSsi/XrdSsiFileSess.hh"
#include "XrdSsi/XrdSsiProvider.hh"
#include "XrdSsi/XrdSsiService.hh"
#include "XrdSsi/XrdSsiSfs.hh"
#include "XrdSsi/XrdSsiStream.hh"
#include "XrdSsi/XrdSsiTrace.hh"
Expand All @@ -67,6 +68,7 @@ namespace XrdSsi
{
extern XrdOucBuffPool *BuffPool;
extern XrdSsiProvider *Provider;
extern XrdSsiService *Service;
extern XrdSysError Log;
extern int respWT;
};
Expand Down Expand Up @@ -393,7 +395,7 @@ int XrdSsiFileSess::open(const char *path, // In

// Notify the provider that we will be executing a request
//
if (Provider->Prepare(errInfo, fileResource))
if (Service->Prepare(errInfo, fileResource))
{const char *usr = fileResource.rUser.c_str();
if (!(*usr)) gigID = strdup(path);
else {char gBuff[2048];
Expand Down
34 changes: 0 additions & 34 deletions src/XrdSsi/XrdSsiProvider.hh
Expand Up @@ -152,40 +152,6 @@ virtual bool Init(XrdSsiLogger *logP,
char **argv
) = 0;

//-----------------------------------------------------------------------------
//! @brief Prepare for processing subsequent resource request.
//!
//! This method is meant to be used server-side to optimize subsequent request
//! processing, perform authorization, and allow a provider to stall or redirect
//! requests. It is optional and a default implementation is provided.
//!
//! @param eInfo The object where error information is to be placed.
//! @param rDesc Reference to the resource object that describes the
//! resource subsequent requests will use.
//!
//! @return true Continue normally, no issues detected.
//! false An exception occurred, the eInfo object has the reason.
//!
//! Special notes for server-side processing:
//!
//! 1) Two special errors are recognized that allow for a client retry:
//!
//! resP->eInfo.eNum = EAGAIN (client should retry elsewhere)
//! resP->eInfo.eMsg = the host name where the client is redirected
//! resP->eInfo.eArg = the port number to be used by the client
//!
//! resP->eInfo.eNum = EBUSY (client should wait and then retry).
//! resP->eInfo.eMsg = an optional reason for the wait.
//! resP->eInfo.eArg = the number of seconds the client should wait.
//-----------------------------------------------------------------------------

virtual bool Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &rDesc)
{if (QueryResource(rDesc.rName.c_str()) != notPresent)
return true;
eInfo.Set("Resource not available.", ENOENT);
return false;
}

//-----------------------------------------------------------------------------
//! Obtain the status of a resource.
//! Client-side: This method can be called to obtain the availability of a
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiRequest.hh
Expand Up @@ -86,7 +86,7 @@ friend class XrdSsiTaskReal;
//! you have consumed the message to release its resources.
//-----------------------------------------------------------------------------

virtual void Alert(XrdSsiRespInfoMsg &aMsg) {aMsg.Recycle(false);}
virtual void Alert(XrdSsiRespInfoMsg &aMsg) {aMsg.RecycleMsg(false);}

//-----------------------------------------------------------------------------
//! Indicate that request processing has been finished. This method calls
Expand Down
8 changes: 4 additions & 4 deletions src/XrdSsi/XrdSsiRespInfo.hh
Expand Up @@ -76,8 +76,8 @@ struct XrdSsiRespInfo

//-----------------------------------------------------------------------------
//! The RespInfoMsg class describes an async response message sent to the
//! XrdSsiRequest::Alert() method. It encapsulates the message sent and is
//! responsible for recovering any resources used by the message via Recycle().
//! XrdSsiRequest::Alert() method. It encapsulates the message sent and must
//! recover any resources used by the message when RecycleMsg() is called.
//-----------------------------------------------------------------------------

class XrdSsiRespInfoMsg
Expand All @@ -99,10 +99,10 @@ inline char *GetMsg(int &mlen) {mlen = msgLen; return msgBuf;}
//! Release resources used by the message. This method must be called after the
//! message is processed by the XrdSsiRequest::Alert() method.
//!
//! Qparam sent When true, the message was sent. Otherwise, it was not sent.
//! @param sent When true, the message was sent. Otherwise, it was not sent.
//-----------------------------------------------------------------------------

virtual void Recycle(bool sent=true) = 0;
virtual void RecycleMsg(bool sent=true) = 0;

//-----------------------------------------------------------------------------
//! Contructor
Expand Down
4 changes: 2 additions & 2 deletions src/XrdSsi/XrdSsiResponder.hh
Expand Up @@ -108,15 +108,15 @@ protected:
//! Send an alert message to the request. This is a convenience method that
//! avoids race condistions with Finished() so it is safe to use in all cases.
//! This is a server-side call. The service is responsible for creating a
//! RespInfoMsg object containing the message and supplying a Recycle() method.
//! RespInfoMsg object containing the message and supplying a RecycleMsg() method.
//!
//! @param aMsg reference to the message to be sent.
//-----------------------------------------------------------------------------

inline void Alert(XrdSsiRespInfoMsg &aMsg)
{XrdSsiMutexMon(rrMutex);
if (reqP) reqP->Alert(aMsg);
else aMsg.Recycle(false);
else aMsg.RecycleMsg(false);
}

//-----------------------------------------------------------------------------
Expand Down
58 changes: 58 additions & 0 deletions src/XrdSsi/XrdSsiService.cc
@@ -0,0 +1,58 @@
/******************************************************************************/
/* */
/* X r d S s i S e r v i c e . c c */
/* */
/* (c) 2017 by the Board of Trustees of the Leland Stanford, Jr., University */
/* 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 "XrdSsiProvider.hh"
#include "XrdSsiService.hh"

/******************************************************************************/
/* G l o b a l I t e m s */
/******************************************************************************/

namespace XrdSsi
{
extern XrdSsiProvider *Provider;
}

/******************************************************************************/
/* P r e p a r e */
/******************************************************************************/

bool XrdSsiService::Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &rDesc)
{
// The default implementation simply asks the proviuder if the resource exists
//
if (XrdSsi::Provider
&& XrdSsi::Provider->QueryResource(rDesc.rName.c_str()) !=
XrdSsiProvider::notPresent) return true;

// Indicate we do not have the resource
//
eInfo.Set("Resource not available.", ENOENT);
return false;
}
32 changes: 32 additions & 0 deletions src/XrdSsi/XrdSsiService.hh
Expand Up @@ -47,6 +47,7 @@
//! XrdSsiProviderServer defined in the plugin shared library.
//-----------------------------------------------------------------------------

class XrdSsiErrInfo;
class XrdSsiRequest;
class XrdSsiResource;

Expand Down Expand Up @@ -86,6 +87,37 @@ static const int SsiVersion = 0x00020000;

virtual void Attach(XrdSsiRequest &reqRef, std::string handle) {}

//-----------------------------------------------------------------------------
//! @brief Prepare for processing subsequent resource request.
//!
//! This method is meant to be used server-side to optimize subsequent request
//! processing, perform authorization, and allow a service to stall or redirect
//! requests. It is optional and a default implementation is provided that
//! simply asks the provider if the resource exists on the server. Clients need
//! not call or implement this method.
//!
//! @param eInfo The object where error information is to be placed.
//! @param rDesc Reference to the resource object that describes the
//! resource subsequent requests will use.
//!
//! @return true Continue normally, no issues detected.
//! false An exception occurred, the eInfo object has the reason.
//!
//! Special notes for server-side processing:
//!
//! 1) Two special errors are recognized that allow for a client retry:
//!
//! resP->eInfo.eNum = EAGAIN (client should retry elsewhere)
//! resP->eInfo.eMsg = the host name where the client is redirected
//! resP->eInfo.eArg = the port number to be used by the client
//!
//! resP->eInfo.eNum = EBUSY (client should wait and then retry).
//! resP->eInfo.eMsg = an optional reason for the wait.
//! resP->eInfo.eArg = the number of seconds the client should wait.
//-----------------------------------------------------------------------------

virtual bool Prepare(XrdSsiErrInfo &eInfo, const XrdSsiResource &rDesc);

//-----------------------------------------------------------------------------
//! @brief Process a request; client-side or server-side.
//!
Expand Down
2 changes: 1 addition & 1 deletion src/XrdSsi/XrdSsiTaskReal.cc
Expand Up @@ -78,7 +78,7 @@ class AlertMsg : public XrdSsiRespInfoMsg
{
public:

void Recycle(bool sent=true) {delete respObj; delete this;}
void RecycleMsg(bool sent=true) {delete respObj; delete this;}

AlertMsg(XrdCl::AnyObject *resp, char *dbuff, int dlen)
: XrdSsiRespInfoMsg(dbuff, dlen), respObj(resp) {}
Expand Down

0 comments on commit ab2d315

Please sign in to comment.