XRootD
Loading...
Searching...
No Matches
XrdXrootdCallBack Class Reference

#include <XrdXrootdCallBack.hh>

+ Inheritance diagram for XrdXrootdCallBack:
+ Collaboration diagram for XrdXrootdCallBack:

Public Member Functions

 XrdXrootdCallBack (const char *opn, const char opc)
 
 ~XrdXrootdCallBack ()
 
void Done (int &Result, XrdOucErrInfo *eInfo, const char *Path=0)
 
const char * Func ()
 
char Oper ()
 
int Same (unsigned long long arg1, unsigned long long arg2)
 
void sendError (int rc, XrdOucErrInfo *eInfo, const char *Path)
 
void sendResp (XrdOucErrInfo *eInfo, XResponseType xrt, int *Data=0, const char *Msg=0, int Mlen=0)
 
void sendVesp (XrdOucErrInfo *eInfo, XResponseType xrt, struct iovec *ioV, int ioN)
 
- Public Member Functions inherited from XrdOucEICB
 XrdOucEICB ()
 Constructor and destructor.
 
virtual ~XrdOucEICB ()
 

Static Public Member Functions

static void setVals (XrdSysError *erp, XrdXrootdStats *SIp, XrdScheduler *schp, int port)
 

Detailed Description

Definition at line 43 of file XrdXrootdCallBack.hh.

Constructor & Destructor Documentation

◆ XrdXrootdCallBack()

XrdXrootdCallBack::XrdXrootdCallBack ( const char * opn,
const char opc )
inline

Definition at line 72 of file XrdXrootdCallBack.hh.

73 : Opname(opn), Opcode(opc) {}

◆ ~XrdXrootdCallBack()

XrdXrootdCallBack::~XrdXrootdCallBack ( )
inline

Definition at line 75 of file XrdXrootdCallBack.hh.

75{}

Member Function Documentation

◆ Done()

void XrdXrootdCallBack::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 251 of file XrdXrootdCallBack.cc.

254{
255 XrdXrootdCBJob *cbj;
256
257// Sending an async response may take a long time. So, we schedule the task
258// to run asynchronously from the forces that got us here.
259//
260 if (!(cbj = XrdXrootdCBJob::Alloc(this, eInfo, Path, Result)))
261 {eDest->Emsg("Done",ENOMEM,"get call back job; user",eInfo->getErrUser());
262 if (eInfo->getErrCB()) eInfo->getErrCB()->Done(Result, eInfo);
263 else delete eInfo;
264 } else Sched->Schedule((XrdJob *)cbj);
265}
static XrdSysError eDest(0,"crypto_")
XrdOucString Path
virtual void Done(int &Result, XrdOucErrInfo *eInfo, const char *Path=0)=0
const char * getErrUser()
XrdOucEICB * getErrCB()
void Schedule(XrdJob *jp)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static XrdXrootdCBJob * Alloc(XrdXrootdCallBack *cbF, XrdOucErrInfo *erp, const char *Path, int rval)
XrdScheduler Sched
Definition XrdLinkCtl.cc:54

References XrdXrootdCBJob::Alloc(), XrdOucEICB::Done(), eDest, XrdOucErrInfo::getErrCB(), XrdOucErrInfo::getErrUser(), Path, and XrdScheduler::Schedule().

+ Here is the call graph for this function:

◆ Func()

const char * XrdXrootdCallBack::Func ( )
inline

Definition at line 51 of file XrdXrootdCallBack.hh.

51{return Opname;}

◆ Oper()

char XrdXrootdCallBack::Oper ( )
inline

Definition at line 53 of file XrdXrootdCallBack.hh.

53{return Opcode;}

◆ Same()

int XrdXrootdCallBack::Same ( unsigned long long arg1,
unsigned long long arg2 )
virtual

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 271 of file XrdXrootdCallBack.cc.

272{
273 XrdXrootdReqID ReqID1(arg1), ReqID2(arg2);
274 unsigned char sid1[2], sid2[2];
275 unsigned int inst1, inst2;
276 int lid1, lid2;
277
278 ReqID1.getID(sid1, lid1, inst1);
279 ReqID2.getID(sid2, lid2, inst2);
280 return lid1 == lid2;
281}

References XrdXrootdReqID::getID().

+ Here is the call graph for this function:

◆ sendError()

void XrdXrootdCallBack::sendError ( int rc,
XrdOucErrInfo * eInfo,
const char * Path )

Definition at line 287 of file XrdXrootdCallBack.cc.

290{
291 static const char *TraceID = "fsError";
292 static int Xserr = kXR_ServerError;
293 int ecode;
294 const char *eMsg = eInfo->getErrText(ecode);
295 const char *User = eInfo->getErrUser();
296
297// Process the data response vector (we need to do this here)
298//
299 if (rc == SFS_DATAVEC)
300 {if (ecode > 1) sendVesp(eInfo, kXR_ok, (struct iovec *)eMsg, ecode);
301 else sendResp(eInfo, kXR_ok, 0);
302 return;
303 }
304
305// Optimize error message handling here
306//
307 if (eMsg && !*eMsg) eMsg = 0;
308
309// Process standard errors
310//
311 if (rc == SFS_ERROR)
312 {SI->errorCnt++;
313 rc = XProtocol::mapError(ecode);
314 sendResp(eInfo, kXR_error, &rc, eMsg, eInfo->getErrTextLen()+1);
315 return;
316 }
317
318// Process the redirection (error msg is host:port)
319//
320 if (rc == SFS_REDIRECT)
321 {SI->redirCnt++;
322 if (ecode <= 0) ecode = (ecode ? -ecode : Port);
323 TRACE(REDIR, User <<" async redir to " << eMsg <<':' <<ecode <<' '
324 <<(Path ? Path : ""));
325 sendResp(eInfo, kXR_redirect, &ecode, eMsg, eInfo->getErrTextLen());
327 XrdXrootdMonitor::Redirect(eInfo->getErrMid(),eMsg,ecode,Opcode,Path);
328 return;
329 }
330
331// Process the deferal
332//
333 if (rc >= SFS_STALL)
334 {SI->stallCnt++;
335 TRACE(STALL, "Stalling " <<User <<" for " <<rc <<" sec");
336 sendResp(eInfo, kXR_wait, &rc, eMsg, eInfo->getErrTextLen()+1);
337 return;
338 }
339
340// Process the data response
341//
342 if (rc == SFS_DATA)
343 {if (ecode) sendResp(eInfo, kXR_ok, 0, eMsg, ecode);
344 else sendResp(eInfo, kXR_ok, 0);
345 return;
346 }
347
348// Unknown conditions, report it
349//
350 {char buff[64];
351 SI->errorCnt++;
352 ecode = sprintf(buff, "Unknown sfs response code %d", rc);
353 eDest->Emsg("sendError", buff);
354 sendResp(eInfo, kXR_error, &Xserr, buff, ecode+1);
355 return;
356 }
357}
@ kXR_ServerError
@ kXR_redirect
Definition XProtocol.hh:904
@ kXR_ok
Definition XProtocol.hh:899
@ kXR_wait
Definition XProtocol.hh:905
@ kXR_error
Definition XProtocol.hh:903
#define eMsg(x)
#define SFS_DATAVEC
#define SFS_DATA
#define SFS_ERROR
#define SFS_REDIRECT
#define SFS_STALL
#define TRACE(act, x)
Definition XrdTrace.hh:63
static int mapError(int rc)
const char * getErrText()
void sendResp(XrdOucErrInfo *eInfo, XResponseType xrt, int *Data=0, const char *Msg=0, int Mlen=0)
void sendVesp(XrdOucErrInfo *eInfo, XResponseType xrt, struct iovec *ioV, int ioN)
XrdXrootdStats * SI

References eDest, eMsg, XrdXrootdStats::errorCnt, XrdOucErrInfo::getErrMid(), XrdOucErrInfo::getErrText(), XrdOucErrInfo::getErrTextLen(), XrdOucErrInfo::getErrUser(), kXR_error, kXR_ok, kXR_redirect, kXR_ServerError, kXR_wait, XProtocol::mapError(), Path, XrdXrootdStats::redirCnt, XrdXrootdMonitor::Redirect(), sendResp(), sendVesp(), SFS_DATA, SFS_DATAVEC, SFS_ERROR, SFS_REDIRECT, SFS_STALL, XrdXrootdStats::stallCnt, and TRACE.

+ Here is the call graph for this function:

◆ sendResp()

void XrdXrootdCallBack::sendResp ( XrdOucErrInfo * eInfo,
XResponseType xrt,
int * Data = 0,
const char * Msg = 0,
int Mlen = 0 )

Definition at line 363 of file XrdXrootdCallBack.cc.

368{
369 static const char *TraceID = "sendResp";
370 struct iovec rspVec[4];
371 XrdXrootdReqID ReqID;
372 int dlen = 0, n = 1;
373 kXR_int32 xbuf;
374
375 if (Data)
376 {xbuf = static_cast<kXR_int32>(htonl(*Data));
377 rspVec[n].iov_base = (caddr_t)(&xbuf);
378 dlen = rspVec[n].iov_len = sizeof(xbuf); n++; // 1
379 }
380 if (Msg && *Msg)
381 { rspVec[n].iov_base = (caddr_t)Msg;
382 dlen += rspVec[n].iov_len = Mlen; n++; // 2
383 }
384
385// Set the destination
386//
387 ReqID.setID(eInfo->getErrArg());
388
389// Send the async response
390//
391 if (XrdXrootdResponse::Send(ReqID, Status, rspVec, n, dlen) < 0)
392 eDest->Emsg("sendResp", eInfo->getErrUser(), Opname,
393 "async resp aborted; user gone.");
394 else if (TRACING(TRACE_RSP))
395 {XrdXrootdResponse theResp;
396 theResp.Set(ReqID.Stream());
397 TRACE(RSP, eInfo->getErrUser() <<" async " <<theResp.ID()
398 <<' ' <<Opname <<" status " <<Status);
399 }
400
401// Release any external buffer from the errinfo object
402//
403 if (eInfo->extData()) eInfo->Reset();
404}
int kXR_int32
Definition XPtypes.hh:89
#define TRACE_RSP
#define TRACING(x)
Definition XrdTrace.hh:70
unsigned long long getErrArg()
void Reset()
Reset object to no message state. Call this method to release appendages.
void Set(XrdLink *lp)

References eDest, XrdOucErrInfo::extData(), XrdOucErrInfo::getErrArg(), XrdOucErrInfo::getErrUser(), XrdXrootdResponse::ID(), XrdOucErrInfo::Reset(), XrdXrootdResponse::Send(), XrdXrootdResponse::Set(), TRACE, TRACE_RSP, and TRACING.

Referenced by sendError().

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

◆ sendVesp()

void XrdXrootdCallBack::sendVesp ( XrdOucErrInfo * eInfo,
XResponseType xrt,
struct iovec * ioV,
int ioN )

Definition at line 410 of file XrdXrootdCallBack.cc.

414{
415 static const char *TraceID = "sendVesp";
416 XrdXrootdReqID ReqID;
417 int dlen = 0;
418
419// Calculate the amount of data being sent
420//
421 for (int i = 1; i < ioN; i++) dlen += ioV[i].iov_len;
422
423// Set the destination
424//
425 ReqID.setID(eInfo->getErrArg());
426
427// Send the async response
428//
429 if (XrdXrootdResponse::Send(ReqID, Status, ioV, ioN, dlen) < 0)
430 eDest->Emsg("sendResp", eInfo->getErrUser(), Opname,
431 "async resp aborted; user gone.");
432 else if (TRACING(TRACE_RSP))
433 {XrdXrootdResponse theResp;
434 theResp.Set(ReqID.Stream());
435 TRACE(RSP, eInfo->getErrUser() <<" async " <<theResp.ID()
436 <<' ' <<Opname <<" status " <<Status);
437 }
438
439// Release any external buffer from the errinfo object
440//
441 if (eInfo->extData()) eInfo->Reset();
442}
void setID(unsigned long long id)
unsigned char * Stream()

References eDest, XrdOucErrInfo::extData(), XrdOucErrInfo::getErrArg(), XrdOucErrInfo::getErrUser(), XrdXrootdResponse::ID(), XrdOucErrInfo::Reset(), XrdXrootdResponse::Send(), XrdXrootdResponse::Set(), XrdXrootdReqID::setID(), XrdXrootdReqID::Stream(), TRACE, TRACE_RSP, and TRACING.

Referenced by sendError().

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

◆ setVals()

void XrdXrootdCallBack::setVals ( XrdSysError * erp,
XrdXrootdStats * SIp,
XrdScheduler * schp,
int port )
static

Definition at line 448 of file XrdXrootdCallBack.cc.

452{
453// Set values into out unnamed static space
454//
455 eDest = erp;
456 SI = SIp;
457 Sched = schp;
458 Port = port;
459}

References eDest.

Referenced by XrdXrootdProtocol::Configure().

+ Here is the caller graph for this function:

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