00001 #ifndef __XRDSSIRESPONDER_HH__ 00002 #define __XRDSSIRESPONDER_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S s i R e s p o n d e r . h h */ 00006 /* */ 00007 /* (c) 2013 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00010 /* */ 00011 /* This file is part of the XRootD software suite. */ 00012 /* */ 00013 /* XRootD is free software: you can redistribute it and/or modify it under */ 00014 /* the terms of the GNU Lesser General Public License as published by the */ 00015 /* Free Software Foundation, either version 3 of the License, or (at your */ 00016 /* option) any later version. */ 00017 /* */ 00018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00021 /* License for more details. */ 00022 /* */ 00023 /* You should have received a copy of the GNU Lesser General Public License */ 00024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00026 /* */ 00027 /* The copyright holder's institutional names and contributor's names may not */ 00028 /* be used to endorse or promote products derived from this software without */ 00029 /* specific prior written permission of the institution or contributor. */ 00030 /******************************************************************************/ 00031 00032 #include <stdlib.h> 00033 #include <string.h> 00034 00035 #include "XrdSsi/XrdSsiRequest.hh" 00036 00037 //----------------------------------------------------------------------------- 00064 //----------------------------------------------------------------------------- 00065 00066 class XrdSsiStream; 00067 00068 class XrdSsiResponder 00069 { 00070 public: 00071 friend class XrdSsiRequest; 00072 friend class XrdSsiRRAgent; 00073 00074 //----------------------------------------------------------------------------- 00079 //----------------------------------------------------------------------------- 00080 00081 static const int MaxDirectXfr = 2097152; //< Max (metadata+data) direct xfr 00082 00083 //----------------------------------------------------------------------------- 00089 //----------------------------------------------------------------------------- 00090 00091 void BindRequest(XrdSsiRequest &rqstR); 00092 00093 //----------------------------------------------------------------------------- 00101 //----------------------------------------------------------------------------- 00102 00103 bool UnBindRequest(); 00104 00105 protected: 00106 00107 //----------------------------------------------------------------------------- 00114 //----------------------------------------------------------------------------- 00115 00116 void Alert(XrdSsiRespInfoMsg &aMsg); 00117 00118 //----------------------------------------------------------------------------- 00130 //----------------------------------------------------------------------------- 00131 00132 virtual void Finished( XrdSsiRequest &rqstR, 00133 const XrdSsiRespInfo &rInfo, 00134 bool cancel=false) = 0; 00135 00136 //----------------------------------------------------------------------------- 00145 //----------------------------------------------------------------------------- 00146 00147 char *GetRequest(int &dlen); 00148 00149 //----------------------------------------------------------------------------- 00153 //----------------------------------------------------------------------------- 00154 00155 void ReleaseRequestBuffer(); 00156 00157 //----------------------------------------------------------------------------- 00160 //----------------------------------------------------------------------------- 00161 00162 enum Status {wasPosted=0, 00163 notPosted, 00164 00165 00166 notActive 00167 }; 00168 00169 //----------------------------------------------------------------------------- 00178 //----------------------------------------------------------------------------- 00179 00180 static const int MaxMetaDataSZ = 2097152; 00181 00182 Status SetMetadata(const char *buff, int blen); 00183 00184 //----------------------------------------------------------------------------- 00192 //----------------------------------------------------------------------------- 00193 00194 Status SetErrResponse(const char *eMsg, int eNum); 00195 00196 //----------------------------------------------------------------------------- 00200 //----------------------------------------------------------------------------- 00201 00202 inline Status SetNilResponse() {return SetResponse((const char *)0,0);} 00203 00204 //----------------------------------------------------------------------------- 00212 //----------------------------------------------------------------------------- 00213 00214 Status SetResponse(const char *buff, int blen); 00215 00216 //----------------------------------------------------------------------------- 00223 //----------------------------------------------------------------------------- 00224 00225 Status SetResponse(long long fsize, int fdnum); 00226 00227 //----------------------------------------------------------------------------- 00234 //----------------------------------------------------------------------------- 00235 00236 Status SetResponse(XrdSsiStream *strmP); 00237 00238 //----------------------------------------------------------------------------- 00241 //----------------------------------------------------------------------------- 00242 00243 XrdSsiResponder(); 00244 00245 //----------------------------------------------------------------------------- 00248 //----------------------------------------------------------------------------- 00249 00250 protected: 00251 00252 virtual ~XrdSsiResponder(); 00253 00254 private: 00255 00256 // The spMutex protects the reqP pointer. It is a hiearchical mutex in that it 00257 // may be obtained prior to obtaining the mutex protecting the request without 00258 // fear of a deadlock (the reverse is not possible). If reqP is zero then 00259 // this responder is not bound to a request. 00260 // 00261 XrdSsiMutex spMutex; 00262 XrdSsiRequest *reqP; 00263 long long rsvd1; // Reserved fields for extensions with ABI compliance 00264 long long rsvd2; 00265 long long rsvd3; 00266 }; 00267 #endif