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 DeferredFinalize();
69
70 void Finalize();
71
73
74 void Finished( XrdSsiRequest &rqstR,
75 const XrdSsiRespInfo &rInfo,
76 bool cancel=false) {}
77
78 char *GetRequest(int &rLen);
79
80 bool ProcessResponse(const XrdSsiErrInfo &eInfo,
81 const XrdSsiRespInfo &resp);
82
83 XrdSfsXferSize Read(bool &done,
84 char *buffer,
85 XrdSfsXferSize blen);
86
87 void RelRequestBuffer();
88
89 int Send(XrdSfsDio *sfDio, XrdSfsXferSize size);
90
91static void SetMax(int mVal) {freeMax = mVal;}
92
93 bool WantResponse(XrdOucErrInfo &eInfo);
94
95// OucEICB methods
96//
97 void Done(int &Result, XrdOucErrInfo *cbInfo,
98 const char *path=0);
99
100 int Same(unsigned long long arg1, unsigned long long arg2)
101 {return 0;}
102// Job methods
103//
104 void DoIt();
105
106// Constructor and destructor
107//
108 XrdSsiFileReq(const char *cID=0)
109 : frqMutex(XrdSsiMutex::Recursive)
110 {Init(cID);}
111
112virtual ~XrdSsiFileReq() {if (tident) free(tident);}
113
116
117private:
118
119void BindDone(); // Override
120void Dispose(); // Override
121int Emsg(const char *pfx, int ecode, const char *op);
122int Emsg(const char *pfx, XrdSsiErrInfo &eObj,
123 const char *op);
124void Init(const char *cID=0);
125XrdSfsXferSize readStrmA(XrdSsiStream *strmP, char *buff,
126 XrdSfsXferSize blen);
127XrdSfsXferSize readStrmP(XrdSsiStream *strmP, char *buff,
128 XrdSfsXferSize blen);
129int sendStrmA(XrdSsiStream *strmP, XrdSfsDio *sfDio,
130 XrdSfsXferSize blen);
131void Recycle();
132void WakeUp(XrdSsiAlert *aP=0);
133
134static XrdSysMutex aqMutex;
135static XrdSsiFileReq *freeReq;
136static int freeCnt;
137static int freeMax;
138
139XrdSsiMutex frqMutex;
140XrdSsiFileReq *nextReq;
141XrdSysSemaphore *finWait;
142XrdOucEICB *respCB;
143unsigned long long respCBarg;
144
145XrdSsiAlert *alrtSent;
146XrdSsiAlert *alrtPend;
147XrdSsiAlert *alrtLast;
148
149char *tident;
150const char *sessN;
151XrdOucErrInfo *cbInfo;
152XrdSsiFileResource *fileR;
153XrdSsiFileSess *fileP;
154char *respBuf;
155long long respOff;
156union {long long fileSz;
157 int respLen;
158 };
159XrdSfsXioHandle sfsBref;
160XrdOucBuffer *oucBuff;
161XrdSsiStream::Buffer *strBuff;
162reqState myState;
163rspState urState;
164int reqSize;
165unsigned int reqID;
166bool haveResp;
167bool respWait;
168bool strmEOF;
169bool schedDone;
170bool isEnding;
171char rID[8];
172};
173#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)
void DeferredFinalize()
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)