xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdSsiResponder.hh
Go to the documentation of this file.
1 #ifndef __XRDSSIRESPONDER_HH__
2 #define __XRDSSIRESPONDER_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d S s i R e s p o n d e r . 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 <cstdlib>
33 #include <cstring>
34 
35 #include "XrdSsi/XrdSsiRequest.hh"
36 
37 //-----------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------
65 
66 class XrdSsiStream;
67 
69 {
70 public:
71 friend class XrdSsiRequest;
72 friend class XrdSsiRRAgent;
73 
74 //-----------------------------------------------------------------------------
79 //-----------------------------------------------------------------------------
80 
81 static const int MaxDirectXfr = 2097152; //< Max (metadata+data) direct xfr
82 
83 //-----------------------------------------------------------------------------
89 //-----------------------------------------------------------------------------
90 
91  void BindRequest(XrdSsiRequest &rqstR);
92 
93 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
102 
103  bool UnBindRequest();
104 
105 protected:
106 
107 //-----------------------------------------------------------------------------
114 //-----------------------------------------------------------------------------
115 
116  void Alert(XrdSsiRespInfoMsg &aMsg);
117 
118 //-----------------------------------------------------------------------------
130 //-----------------------------------------------------------------------------
131 
132 virtual void Finished( XrdSsiRequest &rqstR,
133  const XrdSsiRespInfo &rInfo,
134  bool cancel=false) = 0;
135 
136 //-----------------------------------------------------------------------------
145 //-----------------------------------------------------------------------------
146 
147  char *GetRequest(int &dlen);
148 
149 //-----------------------------------------------------------------------------
153 //-----------------------------------------------------------------------------
154 
155  void ReleaseRequestBuffer();
156 
157 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
161 
162 enum Status {wasPosted=0,
164  notActive
167  };
168 
169 //-----------------------------------------------------------------------------
178 //-----------------------------------------------------------------------------
179 
180 static const int MaxMetaDataSZ = 2097152;
181 
182  Status SetMetadata(const char *buff, int blen);
183 
184 //-----------------------------------------------------------------------------
192 //-----------------------------------------------------------------------------
193 
194  Status SetErrResponse(const char *eMsg, int eNum);
195 
196 //-----------------------------------------------------------------------------
200 //-----------------------------------------------------------------------------
201 
202 inline Status SetNilResponse() {return SetResponse((const char *)0,0);}
203 
204 //-----------------------------------------------------------------------------
212 //-----------------------------------------------------------------------------
213 
214  Status SetResponse(const char *buff, int blen);
215 
216 //-----------------------------------------------------------------------------
223 //-----------------------------------------------------------------------------
224 
225  Status SetResponse(long long fsize, int fdnum);
226 
227 //-----------------------------------------------------------------------------
234 //-----------------------------------------------------------------------------
235 
237 
238 //-----------------------------------------------------------------------------
241 //-----------------------------------------------------------------------------
242 
243  XrdSsiResponder();
244 
245 //-----------------------------------------------------------------------------
248 //-----------------------------------------------------------------------------
249 
250 protected:
251 
252 virtual ~XrdSsiResponder();
253 
254 private:
255 
256 // The spMutex protects the reqP pointer. It is a hiearchical mutex in that it
257 // may be obtained prior to obtaining the mutex protecting the request without
258 // fear of a deadlock (the reverse is not possible). If reqP is zero then
259 // this responder is not bound to a request.
260 //
263 long long rsvd1; // Reserved fields for extensions with ABI compliance
264 long long rsvd2;
265 long long rsvd3;
266 };
267 #endif
Definition: XrdSsiAtomics.hh:109
Definition: XrdSsiRespInfo.hh:43
long long rsvd3
Definition: XrdSsiResponder.hh:265
Definition: XrdSsiResponder.hh:68
Status SetNilResponse()
Definition: XrdSsiResponder.hh:202
Definition: XrdSsiRespInfo.hh:86
virtual void Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false)=0
Definition: XrdSsiResponder.hh:163
long long rsvd1
Definition: XrdSsiResponder.hh:263
bool UnBindRequest()
XrdSsiRequest * reqP
Definition: XrdSsiResponder.hh:262
static const int MaxMetaDataSZ
2MB metadata limit
Definition: XrdSsiResponder.hh:180
void Alert(XrdSsiRespInfoMsg &aMsg)
virtual ~XrdSsiResponder()
XrdSsiMutex spMutex
Definition: XrdSsiResponder.hh:261
Status SetErrResponse(const char *eMsg, int eNum)
void ReleaseRequestBuffer()
Definition: XrdSsiStream.hh:53
Status
Definition: XrdSsiResponder.hh:162
Definition: XrdSsiRequest.hh:70
long long rsvd2
Definition: XrdSsiResponder.hh:264
Status SetMetadata(const char *buff, int blen)
Status SetResponse(const char *buff, int blen)
Success: The response was successfully posted.
Definition: XrdSsiResponder.hh:162
Failure: Request is no longer active.
Definition: XrdSsiResponder.hh:166
char * GetRequest(int &dlen)
Definition: XrdSsiRRAgent.hh:37
void BindRequest(XrdSsiRequest &rqstR)
static const int MaxDirectXfr
Definition: XrdSsiResponder.hh:81