xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdSsiTaskReal.hh
Go to the documentation of this file.
1 #ifndef __XRDSSITASKREAL_HH__
2 #define __XRDSSITASKREAL_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d S s i T a s k R e a l . h h */
6 /* */
7 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* Produced by Andrew Hanushevsky for Stanford University under contract */
9 /* DE-AC02-76-SFO0515 with the Department of Energy */
10 /* */
11 /* This file is part of the XRootD software suite. */
12 /* */
13 /* XRootD is free software: you can redistribute it and/or modify it under */
14 /* the terms of the GNU Lesser General Public License as published by the */
15 /* Free Software Foundation, either version 3 of the License, or (at your */
16 /* option) any later version. */
17 /* */
18 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21 /* License for more details. */
22 /* */
23 /* You should have received a copy of the GNU Lesser General Public License */
24 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26 /* */
27 /* The copyright holder's institutional names and contributor's names may not */
28 /* be used to endorse or promote products derived from this software without */
29 /* specific prior written permission of the institution or contributor. */
30 /******************************************************************************/
31 
32 #include <cstdio>
33 
34 #include "XrdSsi/XrdSsiErrInfo.hh"
35 #include "XrdSsi/XrdSsiEvent.hh"
36 #include "XrdSsi/XrdSsiStream.hh"
38 
39 class XrdSsiRequest;
40 class XrdSsiSessReal;
41 class XrdSysSemaphore;
42 
44  public XrdSsiStream
45 {
46 public:
47 
49 
50 void Detach(bool force=false);
51 
52 void Finished( XrdSsiRequest &rqstR,
53  const XrdSsiRespInfo &rInfo,
54  bool cancel=false);
55 
56 void *Implementation() {return (void *)this;}
57 
58 bool Kill();
59 
60 inline
61 int ID() {return tskID;}
62 
63 inline
64 void Init(XrdSsiRequest *rP, unsigned short tmo=0)
65  {rqstP = rP, tStat = isPend; tmOut = tmo; wPost = 0;
66  mhPend = false; defer = 0;
67  attList.next = attList.prev = this;
68  if (mdResp) {delete mdResp; mdResp = 0;}
69  }
70 
71 void PostError();
72 
73 const
74 char *RequestID() {return rqstP->GetRequestID();}
75 
76 void SchedError(XrdSsiErrInfo *eInfo=0);
77 
78 void SendError();
79 
80 bool SendRequest(const char *node);
81 
82 int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last);
83 
84 bool SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen);
85 
86 void SetTaskID(uint32_t tid, uint32_t sid)
87  {tskID = tid;
88  snprintf(tident, sizeof(tident), "T %u#%u", sid, tid);
89  }
90 
91 int XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP);
92 
93 void XeqEvFin();
94 
97  sessP(sP), mdResp(0), wPost(0), tskID(0),
98  defer(0), mhPend(false)
99  {}
100 
101  ~XrdSsiTaskReal() {if (mdResp) delete mdResp;}
102 
105 
107 
108 private:
109 
110 bool Ask4Resp();
111 respType GetResp(XrdCl::AnyObject **respP, char *&dbuf, int &dlen);
112 bool RespErr(XrdCl::XRootDStatus *status);
113 
119 char *dataBuff;
122 uint32_t tskID;
123 int defer; // Number of oustanding defer requests
124 unsigned short tmOut;
125 bool mhPend;
126 };
127 #endif
TaskStat
Definition: XrdSsiTaskReal.hh:48
Definition: XrdSsiTaskReal.hh:103
Definition: XrdClAnyObject.hh:32
TaskStat tStat
Definition: XrdSsiTaskReal.hh:121
void SetTaskID(uint32_t tid, uint32_t sid)
Definition: XrdSsiTaskReal.hh:86
Definition: XrdSsiRespInfo.hh:43
XrdCl::AnyObject * mdResp
Definition: XrdSsiTaskReal.hh:117
Definition: XrdSsiTaskReal.hh:106
Definition: XrdSsiResponder.hh:68
int SetBuff(XrdSsiErrInfo &eRef, char *buff, int blen, bool &last)
XrdSsiErrInfo errInfo
Definition: XrdSsiTaskReal.hh:114
XrdSsiRequest * rqstP
Definition: XrdSsiTaskReal.hh:116
Definition: XrdSsiTaskReal.hh:48
bool RespErr(XrdCl::XRootDStatus *status)
~XrdSsiTaskReal()
Definition: XrdSsiTaskReal.hh:101
void Init(XrdSsiRequest *rP, unsigned short tmo=0)
Definition: XrdSsiTaskReal.hh:64
int XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP)
void * Implementation()
Definition: XrdSsiTaskReal.hh:56
Definition: XrdSsiSessReal.hh:44
XrdSsiTaskReal(XrdSsiSessReal *sP)
Definition: XrdSsiTaskReal.hh:95
Definition: XrdSsiTaskReal.hh:48
Definition: XrdSsiTaskReal.hh:48
unsigned short tmOut
Definition: XrdSsiTaskReal.hh:124
XrdSsiTaskReal * prev
Definition: XrdSsiTaskReal.hh:103
const char * RequestID()
Definition: XrdSsiTaskReal.hh:74
respType
Definition: XrdSsiTaskReal.hh:106
const char * GetRequestID()
Definition: XrdSsiRequest.hh:147
Definition: XrdSsiTaskReal.hh:106
XrdSsiSessReal * sessP
Definition: XrdSsiTaskReal.hh:115
uint32_t tskID
Definition: XrdSsiTaskReal.hh:122
Definition: XrdSysPthread.hh:493
int defer
Definition: XrdSsiTaskReal.hh:123
respType GetResp(XrdCl::AnyObject **respP, char *&dbuf, int &dlen)
int dataRlen
Definition: XrdSsiTaskReal.hh:120
dlQ attList
Definition: XrdSsiTaskReal.hh:104
Request status.
Definition: XrdClXRootDResponses.hh:218
bool mhPend
Definition: XrdSsiTaskReal.hh:125
int ID()
Definition: XrdSsiTaskReal.hh:61
Definition: XrdSsiTaskReal.hh:106
char * dataBuff
Definition: XrdSsiTaskReal.hh:119
Definition: XrdSsiTaskReal.hh:48
void Detach(bool force=false)
Definition: XrdSsiStream.hh:144
Definition: XrdSsiTaskReal.hh:106
Definition: XrdSsiStream.hh:53
Definition: XrdSsiEvent.hh:36
Definition: XrdSsiErrInfo.hh:40
Definition: XrdSsiRequest.hh:70
XrdSsiTaskReal * next
Definition: XrdSsiTaskReal.hh:103
void Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false)
bool SendRequest(const char *node)
char tident[24]
Definition: XrdSsiEvent.hh:62
Definition: XrdSsiTaskReal.hh:48
Definition: XrdSsiTaskReal.hh:43
void SchedError(XrdSsiErrInfo *eInfo=0)
Definition: XrdSsiTaskReal.hh:48
XrdSysSemaphore * wPost
Definition: XrdSsiTaskReal.hh:118