Loading...
Searching...
No Matches
XrdSsiResponder Class Referenceabstract

`#include <XrdSsiResponder.hh>`

Inheritance diagram for XrdSsiResponder:
Collaboration diagram for XrdSsiResponder:

## Public Member Functions

void | BindRequest (XrdSsiRequest &rqstR)
bool | UnBindRequest ()

## Static Public Attributes

static const int | MaxDirectXfr = 2097152

## Protected Types

enum | Status { wasPosted =0 , notPosted , notActive }

## Protected Member Functions

| XrdSsiResponder ()
virtual | ~XrdSsiResponder ()
void | Alert (XrdSsiRespInfoMsg &aMsg)
virtual void | Finished (XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false)=0
char * | GetRequest (int &dlen)
void | ReleaseRequestBuffer ()
Status | SetErrResponse (const char *eMsg, int eNum)
Status | SetMetadata (const char *buff, int blen)
Status | SetNilResponse ()
Status | SetResponse (const char *buff, int blen)
Status | SetResponse (long long fsize, int fdnum)
Status | SetResponse (XrdSsiStream *strmP)

## Static Protected Attributes

static const int | MaxMetaDataSZ = 2097152
| 2MB metadata limit

## Friends

class | XrdSsiRequest
class | XrdSsiRRAgent

## Detailed Description

Definition at line 68 of file XrdSsiResponder.hh.

## Member Enumeration Documentation

## Status

enum XrdSsiResponder::Status

protected

The following enums are returned by SetMetadata() and SetResponse() to indicate ending status.

Enumerator
wasPosted | Success: The response was successfully posted.
notPosted | Failure: A request was not bound to this object or a response has already been posted or the metadata length was invalid
notActive | Failure: Request is no longer active.

Definition at line 162 of file XrdSsiResponder.hh.

{wasPosted=0,
notPosted,
notActive
};
XrdSsiResponder::notActive
@ notActive
Failure: Request is no longer active.
Definition XrdSsiResponder.hh:166
XrdSsiResponder::notPosted
@ notPosted
Definition XrdSsiResponder.hh:163
XrdSsiResponder::wasPosted
@ wasPosted
Success: The response was successfully posted.
Definition XrdSsiResponder.hh:162

## Constructor & Destructor Documentation

## XrdSsiResponder()

XrdSsiResponder::XrdSsiResponder | ( |  | ) |

protected

This class is meant to be inherited by an object that will actually posts responses.

Definition at line 96 of file XrdSsiResponder.cc.

: spMutex(XrdSsiMutex::Recursive), reqP(0),
rsvd1(0), rsvd2(0), rsvd3(0)
{}
XrdSsiMutex::Recursive
@ Recursive
Definition XrdSsiAtomics.hh:119

## ~XrdSsiResponder()

XrdSsiResponder::~XrdSsiResponder | ( |  | ) |

protected virtual

Destructor is protected. You cannot use delete on a responder object, as it is meant to be inherited by a class and not separately instantiated.

Definition at line 105 of file XrdSsiResponder.cc.

{
// Lock ourselves (unlikely that we need to).
//
spMutex.Lock();
// If we haven't taken a trip to Finished() then we need todo it here. The
// issue we have is that this object may be deleted before Finished() is called
// which is quite dicey. So, we defer it until Finished() is called. This is
// only an issue server-side as we don't control the finish process.
//
if (reqP)
{reqP->rrMutex->Lock();
if (reqP->theRespond == this)
{reqP->theRespond = &ForceUnBind;
reqP->rrMutex->UnLock();
} else if (reqP->theRespond == 0) // Finish() has been called
{reqP->rrMutex->UnLock();
reqP->Dispose();
}
}
// All done
//
spMutex.UnLock();
}

## Member Function Documentation

## Alert()

void XrdSsiResponder::Alert | ( | XrdSsiRespInfoMsg & | aMsg | ) |

protected

Send an alert message to the request. This is a convenience method that avoids race conditions 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 RecycleMsg() method.

Parameters

  aMsg | reference to the message to be sent.

Definition at line 136 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon lck(spMutex);
// If we have a request pointer then forward the alert. Otherwise, deep-six it
//
if (reqP) reqP->Alert(aMsg);
else aMsg.RecycleMsg(false);
}
XrdSsiRespInfoMsg::RecycleMsg
virtual void RecycleMsg(bool sent=true)=0

References XrdSsiRespInfoMsg::RecycleMsg().

Here is the call graph for this function:

## BindRequest()

void XrdSsiResponder::BindRequest | ( | XrdSsiRequest & | rqstR | ) |

Take ownership of a request object by binding the request object to a responder object. This method must be called by the responder before posting any responses.

Parameters

  rqstR | reference to the request object.

Definition at line 150 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon lck(spMutex);
// Get the request lock and link the request to this object and vice versa
//
rqstR.rrMutex->Lock();
reqP = &rqstR;
rqstR.theRespond = this;
// Initialize the request object
//
rqstR.Resp.Init();
rqstR.errInfo.Clr();
// Notify the request that the bind comleted (this is only used on the
// server to allow a pending finish request to be sent to the responder).
//
rqstR.BindDone();
// Unlock the request. The responder is unlocked upon return
//
rqstR.rrMutex->UnLock();
}
XrdSsiErrInfo::Clr
void Clr()
Reset and clear error information.
Definition XrdSsiErrInfo.hh:48
XrdSsiMutex::UnLock
void UnLock()
Definition XrdSsiAtomics.hh:117
XrdSsiMutex::Lock
void Lock()
Definition XrdSsiAtomics.hh:115
XrdSsiRespInfo::Init
void Init()
Definition XrdSsiRespInfo.hh:61

References XrdSsiErrInfo::Clr(), XrdSsiRespInfo::Init(), XrdSsiMutex::Lock(), XrdSsiMutex::UnLock(), and XrdSsiRequest.

Referenced by PostError::PostError().

Here is the call graph for this function:
Here is the caller graph for this function:

## Finished()

virtual void XrdSsiResponder::Finished | ( | XrdSsiRequest & | rqstR,
|  | const XrdSsiRespInfo & | rInfo,
|  | bool | cancel = false )

protected pure virtual

Notify the responder that a request either completed or was canceled. This allows the responder to release any resources given to the request object (e.g. data response buffer or a stream). This method is invoked when XrdSsiRequest::Finished() is called by the client.

Parameters

  rqstR | reference to the object describing the request.
  rInfo | reference to the object describing the response.
  cancel | False -> the request/response interaction completed. True -> the request/response interaction aborted because of an error or the client requested that the request be canceled.

Implemented in PostError, and XrdSsiTaskReal.

References XrdSsiRequest.

Referenced by XrdSsiRequest::Finished().

Here is the call graph for this function:
Here is the caller graph for this function:

## GetRequest()

char * XrdSsiResponder::GetRequest | ( | int & | dlen | ) |

protected

Obtain the request data sent by a client.

Note: This method is called with the object's recursive mutex unlocked!

Parameters

  dlen | holds the length of the request after the call.

Returns
  =0 No request data available, dlen has been set to zero.
  !0 Pointer to the buffer holding the request, dlen has the length

Definition at line 179 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon lck(spMutex);
// If we have a request pointer, forward the call. Otherwise return nothing.
//
if (reqP) return reqP->GetRequest(dlen);
dlen = 0;
return 0;
}

## ReleaseRequestBuffer()

void XrdSsiResponder::ReleaseRequestBuffer | ( |  | ) |

protected

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.

Definition at line 194 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon lck(spMutex);
// If we have a request, forward the call (note we need to also get the
// the request lock to properly serialize this call).
//
if (reqP) reqP->ReleaseRequestBuffer();
}

Referenced by XrdSsiTaskReal::XeqEvent().

Here is the caller graph for this function:

## SetErrResponse()

XrdSsiResponder::Status XrdSsiResponder::SetErrResponse | ( | const char * | eMsg,
|  | int | eNum )

protected

Set an error response for a request.

Parameters

  eMsg | the message describing the error. The message is copied to private storage.
  eNum | the errno associated with the error.

Returns
  See Status enum for possible values.

Definition at line 229 of file XrdSsiResponder.cc.

{
// Validate object for a response
//
SSI_VAL_RESPONSE;
// Set the error response (we have the right locks now)
//
reqP->errInfo.Set(eMsg, eNum);
reqP->Resp.eMsg = reqP->errInfo.Get(reqP->Resp.eNum).c_str();
reqP->Resp.rType = XrdSsiRespInfo::isError;
// Complete the response
//
SSI_XEQ_RESPONSE;
}
eMsg
#define eMsg(x)
Definition XrdSecsssAdmin.cc:53
SSI_XEQ_RESPONSE
#define SSI_XEQ_RESPONSE
Definition XrdSsiResponder.cc:51
SSI_VAL_RESPONSE
#define SSI_VAL_RESPONSE
Definition XrdSsiResponder.cc:38
XrdSsiRespInfo::isError
@ isError
Definition XrdSsiRespInfo.hh:58

References eMsg, XrdSsiRespInfo::isError, SSI_VAL_RESPONSE, and SSI_XEQ_RESPONSE.

Referenced by PostError::DoIt(), XrdSsiTaskReal::SendError(), and XrdSsiTaskReal::XeqEvent().

Here is the caller graph for this function:

## SetMetadata()

XrdSsiResponder::Status XrdSsiResponder::SetMetadata | ( | const char * | buff,
|  | int | blen )

protected

Definition at line 208 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon lck(spMutex);
// If we don't have a request or the args are invalid, return an error.
//
if (!reqP || blen < 0 || blen > MaxMetaDataSZ) return notPosted;
// Post the metadata
//
reqP->rrMutex->Lock();
reqP->Resp.mdata = buff;
reqP->Resp.mdlen = blen;
reqP->rrMutex->UnLock();
return wasPosted;
}
XrdSsiResponder::MaxMetaDataSZ
static const int MaxMetaDataSZ
2MB metadata limit
Definition XrdSsiResponder.hh:180

References MaxMetaDataSZ, notPosted, and wasPosted.

## SetNilResponse()

Status XrdSsiResponder::SetNilResponse | ( |  | ) |

inline protected

Set a nil response for a request (used for sending only metadata).

Returns
  See Status enum for possible values.

Definition at line 202 of file XrdSsiResponder.hh.

{return SetResponse((const char *)0,0);}
XrdSsiResponder::SetResponse
Status SetResponse(const char *buff, int blen)
Definition XrdSsiResponder.cc:252

References SetResponse().

Here is the call graph for this function:

## SetResponse() [1/3]

XrdSsiResponder::Status XrdSsiResponder::SetResponse | ( | const char * | buff,
|  | int | blen )

protected

Set a memory buffer containing data as the request response.

Parameters

  buff | pointer to a buffer holding the response. The buffer must remain valid until XrdSsiResponder::Finished() is called.
  blen | the length of the response in buff that is to be sent.

Returns
  See Status enum for possible values.

Definition at line 252 of file XrdSsiResponder.cc.

{
// Validate object for a response
//
SSI_VAL_RESPONSE;
// Set the response (we have the right locks now)
//
reqP->Resp.buff = buff;
reqP->Resp.blen = blen;
reqP->Resp.rType = XrdSsiRespInfo::isData;
// Complete the response
//
SSI_XEQ_RESPONSE;
}
XrdSsiRespInfo::isData
@ isData
Definition XrdSsiRespInfo.hh:58

References XrdSsiRespInfo::isData, SSI_VAL_RESPONSE, and SSI_XEQ_RESPONSE.

Referenced by SetNilResponse(), and XrdSsiTaskReal::XeqEvent().

Here is the caller graph for this function:

## SetResponse() [2/3]

XrdSsiResponder::Status XrdSsiResponder::SetResponse | ( | long long | fsize,
|  | int | fdnum )

protected

Set a file containing data as the response.

Parameters

  fsize | the size of the file containing the response.
  fdnum | the file descriptor of the open file.

Returns
  See Status enum for possible values.

Definition at line 272 of file XrdSsiResponder.cc.

{
// Validate object for a response
//
SSI_VAL_RESPONSE;
// Set the response (we have the right locks now)
//
reqP->Resp.fdnum = fdnum;
reqP->Resp.fsize = fsize;
reqP->Resp.rType = XrdSsiRespInfo::isFile;
// Complete the response
//
SSI_XEQ_RESPONSE;
}
XrdSsiRespInfo::isFile
@ isFile
Definition XrdSsiRespInfo.hh:58

References XrdSsiRespInfo::isFile, SSI_VAL_RESPONSE, and SSI_XEQ_RESPONSE.

## SetResponse() [3/3]

XrdSsiResponder::Status XrdSsiResponder::SetResponse | ( | XrdSsiStream * | strmP | ) |

protected

Set a stream object that is to provide data as the response.

Parameters

  strmP | pointer to stream object that is to be used to supply response data. See XrdSsiStream for more details.

Returns
  See Status enum for possible values.

Definition at line 292 of file XrdSsiResponder.cc.

{
// Validate object for a response
//
SSI_VAL_RESPONSE;
// Set the response (we have the right locks now)
//
reqP->Resp.eNum = 0;
reqP->Resp.strmP = strmP;
reqP->Resp.rType = XrdSsiRespInfo::isStream;
// Complete the response
//
SSI_XEQ_RESPONSE;
}
XrdSsiRespInfo::isStream
@ isStream
Definition XrdSsiRespInfo.hh:58

References XrdSsiRespInfo::isStream, SSI_VAL_RESPONSE, and SSI_XEQ_RESPONSE.

## UnBindRequest()

bool XrdSsiResponder::UnBindRequest | ( |  | ) |

Unbind this responder from the request object it is bound to. Upon return ownership of the associated request object reverts back to the creator of the object who is responsible for deleting or recycling the request object. UnBindRequest() is also called when the responder object is deleted.

Returns
  true Request successfully unbound. false UnBindRequest already called or called prior to Finish().

Definition at line 314 of file XrdSsiResponder.cc.

{
XrdSsiMutexMon spMon(spMutex);
// If we are not bound to a request, indicate an error.
//
if (!reqP) return false;
// Lock the request and if Finished() was not called, indicate an error.
//
reqP->rrMutex->Lock();
if (reqP->theRespond != 0)
{reqP->rrMutex->UnLock();
return false;
}
// We have a request pointer and Finish() was called; so do the actual unbind.
//
reqP->rrMutex->UnLock();
reqP->Dispose();
reqP = 0;
return true;
}

Referenced by PostError::Finished().

Here is the caller graph for this function:

## Friends And Related Symbol Documentation

## XrdSsiRequest

friend class XrdSsiRequest

friend

Definition at line 71 of file XrdSsiResponder.hh.

References XrdSsiRequest.

Referenced by PostError::PostError(), BindRequest(), PostError::Finished(), Finished(), XrdSsiTaskReal::Finished(), XrdSsiTaskReal::Init(), and XrdSsiRequest.

## XrdSsiRRAgent

friend class XrdSsiRRAgent

friend

Definition at line 72 of file XrdSsiResponder.hh.

References XrdSsiRRAgent.

Referenced by XrdSsiRRAgent.

## Member Data Documentation

## MaxDirectXfr

const int XrdSsiResponder::MaxDirectXfr = 2097152

static

The maximum amount of metadata+data (i.e. the sum of two blen arguments in SetMetadata() and and SetResponse(const char *buff, int blen), respectively) that may be directly sent to the client without the SSI framework converting the data buffer response into a stream response.

Definition at line 81 of file XrdSsiResponder.hh.

Referenced by XrdSsiFileSess::AttnInfo().

## MaxMetaDataSZ

const int XrdSsiResponder::MaxMetaDataSZ = 2097152

static protected

2MB metadata limit

Set a pointer to metadata to be sent out-of-band ahead of the response.

Parameters

  buff | pointer to a buffer holding the metadata. The buffer must remain valid until XrdSsiResponder::Finished() is called.
  blen | the length of the metadata in buff that is to be sent. It must in the range 0 <= blen <= MaxMetaDataSZ.

Returns
  See Status enum for possible values.

Definition at line 180 of file XrdSsiResponder.hh.

Referenced by SetMetadata().

The documentation for this class was generated from the following files:

- XrdSsiResponder.hh
- XrdSsiResponder.cc