XRootD
Loading...
Searching...
No Matches
XrdSsiFileReq.hh
Go to the documentation of this file.
1#ifndef __SSI_FILEREQ_H__
2#define __SSI_FILEREQ_H__
3/******************************************************************************/
4/* */
5/* X r d S s i F i l e R e q . 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 <cstring>
33#include <sys/types.h>
34
35#include "Xrd/XrdJob.hh"
36#include "Xrd/XrdScheduler.hh"
38#include "XrdSfs/XrdSfsXio.hh"
43
44class XrdOucErrInfo;
45class XrdSsiAlert;
47class XrdSsiFileSess;
49class XrdSsiRRInfo;
50class XrdSsiService;
51class XrdSsiStream;
52
53class XrdSsiFileReq : public XrdSsiRequest, public XrdOucEICB, public XrdJob
54{
55public:
56
57
58// SsiRequest methods
59//
60 void Activate(XrdOucBuffer *oP, XrdSfsXioHandle bR, int rSz);
61
62 void Alert(XrdSsiRespInfoMsg &aMsg);
63
65 XrdSsiFileSess *fP, const char *sn,
66 const char *id, unsigned int rnum);
67
68 void Finalize();
69
71
72 void Finished( XrdSsiRequest &rqstR,
73 const XrdSsiRespInfo &rInfo,
74 bool cancel=false) {}
75
76 char *GetRequest(int &rLen);
77
78 bool ProcessResponse(const XrdSsiErrInfo &eInfo,
79 const XrdSsiRespInfo &resp);
80
81 XrdSfsXferSize Read(bool &done,
82 char *buffer,
83 XrdSfsXferSize blen);
84
85 void RelRequestBuffer();
86
87 int Send(XrdSfsDio *sfDio, XrdSfsXferSize size);
88
89static void SetMax(int mVal) {freeMax = mVal;}
90
91 bool WantResponse(XrdOucErrInfo &eInfo);
92
93// OucEICB methods
94//
95 void Done(int &Result, XrdOucErrInfo *cbInfo,
96 const char *path=0);
97
98 int Same(unsigned long long arg1, unsigned long long arg2)
99 {return 0;}
100// Job methods
101//
102 void DoIt();
103
104// Constructor and destructor
105//
106 XrdSsiFileReq(const char *cID=0)
107 : frqMutex(XrdSsiMutex::Recursive)
108 {Init(cID);}
109
110virtual ~XrdSsiFileReq() {if (tident) free(tident);}
111
114
115private:
116
117void BindDone(); // Override
118void Dispose(); // Override
119int Emsg(const char *pfx, int ecode, const char *op);
120int Emsg(const char *pfx, XrdSsiErrInfo &eObj,
121 const char *op);
122void Init(const char *cID=0);
123XrdSfsXferSize readStrmA(XrdSsiStream *strmP, char *buff,
124 XrdSfsXferSize blen);
125XrdSfsXferSize readStrmP(XrdSsiStream *strmP, char *buff,
126 XrdSfsXferSize blen);
127int sendStrmA(XrdSsiStream *strmP, XrdSfsDio *sfDio,
128 XrdSfsXferSize blen);
129void Recycle();
130void WakeUp(XrdSsiAlert *aP=0);
131
132static XrdSysMutex aqMutex;
133static XrdSsiFileReq *freeReq;
134static int freeCnt;
135static int freeMax;
136
137XrdSsiMutex frqMutex;
138XrdSsiFileReq *nextReq;
139XrdSysSemaphore *finWait;
140XrdOucEICB *respCB;
141unsigned long long respCBarg;
142
143XrdSsiAlert *alrtSent;
144XrdSsiAlert *alrtPend;
145XrdSsiAlert *alrtLast;
146
147char *tident;
148const char *sessN;
149XrdOucErrInfo *cbInfo;
150XrdSsiFileResource *fileR;
151XrdSsiFileSess *fileP;
152char *respBuf;
153long long respOff;
154union {long long fileSz;
155 int respLen;
156 };
157XrdSfsXioHandle sfsBref;
158XrdOucBuffer *oucBuff;
159XrdSsiStream::Buffer *strBuff;
160reqState myState;
161rspState urState;
162int reqSize;
163unsigned int reqID;
164bool haveResp;
165bool respWait;
166bool strmEOF;
167bool schedDone;
168bool isEnding;
169char rID[8];
170};
171#endif
#define tident
int XrdSfsXferSize
class XrdBuffer * XrdSfsXioHandle
Definition XrdSfsXio.hh:46
XrdJob(const char *desc="")
Definition XrdJob.hh:51
XrdOucEICB()
Constructor and destructor.
void Alert(XrdSsiRespInfoMsg &aMsg)
Send or receive a server generated alert.
bool WantResponse(XrdOucErrInfo &eInfo)
XrdSfsXferSize Read(bool &done, char *buffer, XrdSfsXferSize blen)
int Same(unsigned long long arg1, unsigned long long arg2)
char * GetRequest(int &rLen)
void Finished(XrdSsiRequest &rqstR, const XrdSsiRespInfo &rInfo, bool cancel=false)
void RelRequestBuffer()
bool ProcessResponse(const XrdSsiErrInfo &eInfo, const XrdSsiRespInfo &resp)
XrdSsiFileReq(const char *cID=0)
int Send(XrdSfsDio *sfDio, XrdSfsXferSize size)
static XrdSsiFileReq * Alloc(XrdOucErrInfo *eP, XrdSsiFileResource *rP, XrdSsiFileSess *fP, const char *sn, const char *id, unsigned int rnum)
void Activate(XrdOucBuffer *oP, XrdSfsXioHandle bR, int rSz)
virtual ~XrdSsiFileReq()
void Done(int &Result, XrdOucErrInfo *cbInfo, const char *path=0)
static void SetMax(int mVal)
bool Finished(bool cancel=false)
XrdSsiRequest(const char *reqid=0, uint16_t tmo=0)