XRootD
XrdSsiAlert Class Reference

#include <XrdSsiAlert.hh>

+ Inheritance diagram for XrdSsiAlert:
+ Collaboration diagram for XrdSsiAlert:

Public Member Functions

 XrdSsiAlert ()
 
 ~XrdSsiAlert ()
 
void Done (int &Result, XrdOucErrInfo *cbInfo, const char *path=0)
 
void Recycle ()
 
int Same (unsigned long long arg1, unsigned long long arg2)
 
int SetInfo (XrdOucErrInfo &eInfo, char *aMsg, int aLen)
 
- Public Member Functions inherited from XrdOucEICB
 XrdOucEICB ()
 Constructor and destructor. More...
 
virtual ~XrdOucEICB ()
 

Static Public Member Functions

static XrdSsiAlertAlloc (XrdSsiRespInfoMsg &aMsg)
 
static void SetMax (int maxval)
 

Public Attributes

XrdSsiAlertnext
 

Detailed Description

Definition at line 37 of file XrdSsiAlert.hh.

Constructor & Destructor Documentation

◆ XrdSsiAlert()

XrdSsiAlert::XrdSsiAlert ( )
inline

Definition at line 59 of file XrdSsiAlert.hh.

59 {}

Referenced by Alloc().

+ Here is the caller graph for this function:

◆ ~XrdSsiAlert()

XrdSsiAlert::~XrdSsiAlert ( )
inline

Definition at line 60 of file XrdSsiAlert.hh.

60 {}

Member Function Documentation

◆ Alloc()

XrdSsiAlert * XrdSsiAlert::Alloc ( XrdSsiRespInfoMsg aMsg)
static

Definition at line 52 of file XrdSsiAlert.cc.

53 {
54  XrdSsiAlert *aP;
55 
56 // Obtain a lock
57 //
58  aMutex.Lock();
59 
60 // Allocate via stack or a new call
61 //
62  if (!(aP = free)) aP = new XrdSsiAlert();
63  else {free = aP->next; fNum--;}
64 
65 // Unlock mutex
66 //
67  aMutex.UnLock();
68 
69 // Fill out object and return it
70 //
71  aP->next = 0;
72  aP->theMsg = &aMsg;
73  return aP;
74 }
XrdSsiAlert * next
Definition: XrdSsiAlert.hh:41

References XrdSsiAlert(), XrdSysMutex::Lock(), next, and XrdSysMutex::UnLock().

Referenced by XrdSsiFileReq::Alert().

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

◆ Done()

void XrdSsiAlert::Done ( int &  Result,
XrdOucErrInfo eInfo,
const char *  Path = 0 
)
virtual

Invoke a callback after an operation completes.

Parameters
Result- the original function's result (may be changed).
eInfo- Associated error information. The eInfo object may not be modified until it's own callback Done() method is called, if supplied. If the callback function in eInfo is zero, then the eInfo object is deleted by the invoked callback. Otherwise, that method must be invoked by this callback function after the actual callback message is sent. This allows the callback requestor to do post-processing and be asynchronous being assured that the callback completed.
Path- Optionally, the path related to thid request. It is used for tracing and detailed monitoring purposes.

Implements XrdOucEICB.

Definition at line 82 of file XrdSsiAlert.cc.

83 {
84 
85 // This is an async callback so we need to delete our errinfo object.
86 //
87  delete eiP;
88 
89 // Simply recycle this object.
90 //
91  Recycle();
92 }
void Recycle()
Definition: XrdSsiAlert.cc:98

References Recycle().

+ Here is the call graph for this function:

◆ Recycle()

void XrdSsiAlert::Recycle ( void  )

Definition at line 98 of file XrdSsiAlert.cc.

99 {
100 
101 // Issue callback to release the message if we have one
102 //
103  if (theMsg) theMsg->RecycleMsg();
104 
105 // Place object on the queue unless we have too many
106 //
107  aMutex.Lock();
108  if (fNum >= fMax) delete this;
109  else {next = free; free = this; fNum++;}
110  aMutex.UnLock();
111 }
virtual void RecycleMsg(bool sent=true)=0

References XrdSysMutex::Lock(), next, XrdSsiRespInfoMsg::RecycleMsg(), and XrdSysMutex::UnLock().

Referenced by Done(), and XrdSsiFileReq::Finalize().

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

◆ Same()

int XrdSsiAlert::Same ( unsigned long long  arg1,
unsigned long long  arg2 
)
inlinevirtual

Determine if two callback arguments refer to the same client.

Parameters
arg1- The first callback argument.
arg2- The second callback argument.
Returns
!0 - The arguments refer to the same client.
=0 - The arguments refer to the different clients.

Implements XrdOucEICB.

Definition at line 56 of file XrdSsiAlert.hh.

57  {return 0;}

◆ SetInfo()

int XrdSsiAlert::SetInfo ( XrdOucErrInfo eInfo,
char *  aMsg,
int  aLen 
)

Definition at line 117 of file XrdSsiAlert.cc.

118 {
119  static const int aIovSz = 3;
120  struct AlrtResp {struct iovec ioV[aIovSz]; XrdSsiRRInfoAttn aHdr;};
121 
122  AlrtResp *alrtResp;
123  char *mBuff, *aData;
124  int n;
125 
126 // We will be constructing the response in the message buffer. This is
127 // gauranteed to be big enough for our purposes so no need to check the size.
128 //
129  mBuff = eInfo.getMsgBuff(n);
130 
131 // Initialize the response
132 //
133  alrtResp = (AlrtResp *)mBuff;
134  memset(alrtResp, 0, sizeof(AlrtResp));
135  alrtResp->aHdr.pfxLen = htons(sizeof(XrdSsiRRInfoAttn));
136 
137 // Fill out iovec to point to our header
138 //
139 // alrtResp->ioV[0].iov_len = sizeof(XrdSsiRRInfoAttn) + msgBlen;
140  alrtResp->ioV[1].iov_base = mBuff+offsetof(struct AlrtResp, aHdr);
141  alrtResp->ioV[1].iov_len = sizeof(XrdSsiRRInfoAttn);
142 
143 // Fill out the iovec for the alert data
144 //
145  aData = theMsg->GetMsg(n);
146  alrtResp->ioV[2].iov_base = aData;
147  alrtResp->ioV[2].iov_len = n;
148  alrtResp->aHdr.mdLen = htonl(n);
149  alrtResp->aHdr.tag = XrdSsiRRInfoAttn::alrtResp;
150 
151 // Return up to 8 bytes of alert data for debugging purposes
152 //
153  if (aMsg) memcpy(aMsg, aData, (n < (int)sizeof(aMsg) ? n : 8));
154 
155 // Setup to have metadata actually sent to the requestor
156 //
157  eInfo.setErrCode(aIovSz);
158  return n;
159 }
char * getMsgBuff(int &mblen)
int setErrCode(int code)
char * GetMsg(int &mlen)
static const int alrtResp
Definition: XrdSsiRRInfo.hh:91

References XrdSsiRRInfoAttn::alrtResp, XrdSsiRespInfoMsg::GetMsg(), XrdOucErrInfo::getMsgBuff(), and XrdOucErrInfo::setErrCode().

+ Here is the call graph for this function:

◆ SetMax()

static void XrdSsiAlert::SetMax ( int  maxval)
inlinestatic

Definition at line 49 of file XrdSsiAlert.hh.

49 {fMax = maxval;}

Member Data Documentation

◆ next

XrdSsiAlert* XrdSsiAlert::next

Definition at line 41 of file XrdSsiAlert.hh.

Referenced by XrdSsiFileReq::Alert(), Alloc(), XrdSsiFileReq::Finalize(), and Recycle().


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