XRootD
XrdSsiSessReal.hh
Go to the documentation of this file.
1 #ifndef __XRDSSISESSREAL_HH__
2 #define __XRDSSISESSREAL_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d S s i S e s s 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 <cstring>
33 
34 #include "XrdCl/XrdClFile.hh"
35 
36 #include "XrdSsi/XrdSsiAtomics.hh"
37 #include "XrdSsi/XrdSsiEvent.hh"
38 
39 #include "XrdSys/XrdSysPthread.hh"
40 
41 class XrdSsiServReal;
42 class XrdSsiTaskReal;
43 
45 {
46 public:
47 
49 
50 const char *GetKey() {return resKey;}
51 
52 uint32_t GetSID() {return sessID;}
53 
54  void InitSession(XrdSsiServReal *servP,
55  const char *sName,
56  int uent,
57  bool hold,
58  bool newSID=false);
59 
60  void Lock() {sessMutex.Lock();}
61 
62 XrdSsiMutex *MutexP() {return &sessMutex;}
63 
64  bool Provision(XrdSsiRequest *reqP, const char *epURL);
65 
66  bool Run(XrdSsiRequest *reqP);
67 
68  void SetKey(const char *key)
69  {if (resKey) free(resKey);
70  resKey = (key ? strdup(key) : 0);
71  }
72 
73  void TaskFinished(XrdSsiTaskReal *tP);
74 
75  void UnHold(bool cleanup=true);
76 
77  void UnLock() {sessMutex.UnLock();}
78 
79  bool Unprovision();
80 
81  int XeqEvent(XrdCl::XRootDStatus *status,
82  XrdCl::AnyObject **respP);
83 
84  void XeqEvFin() {}
85 
87  const char *sName,
88  int uent,
89  bool hold=false)
90  : sessMutex(XrdSsiMutex::Recursive),
91  resKey(0), sessName(0), sessNode(0)
92  {InitSession(servP, sName, uent, hold, true);}
93 
95 
97 
98 private:
99 XrdSsiTaskReal *NewTask(XrdSsiRequest *reqP);
100 void RelTask(XrdSsiTaskReal *tP);
101 void Shutdown(XrdCl::XRootDStatus &epStatus, bool onClose);
102 
103 XrdSsiMutex sessMutex;
104 XrdSsiServReal *myService;
105 XrdSsiTaskReal *attBase;
106 XrdSsiTaskReal *freeTask;
107 XrdSsiRequest *requestP;
108 char *resKey;
109 char *sessName;
110 char *sessNode;
111 uint32_t sessID;
112 uint32_t nextTID;
113 uint32_t alocLeft;
114 int16_t uEnt; // User index for scaling
115 bool isHeld;
116 bool inOpen;
117 bool noReuse;
118 };
119 #endif
A file.
Definition: XrdClFile.hh:46
XrdSsiMutex * MutexP()
uint32_t GetSID()
void InitSession(XrdSsiServReal *servP, const char *sName, int uent, bool hold, bool newSID=false)
void SetKey(const char *key)
bool Provision(XrdSsiRequest *reqP, const char *epURL)
bool Run(XrdSsiRequest *reqP)
int XeqEvent(XrdCl::XRootDStatus *status, XrdCl::AnyObject **respP)
const char * GetKey()
XrdCl::File epFile
XrdSsiSessReal * nextSess
void UnHold(bool cleanup=true)
void TaskFinished(XrdSsiTaskReal *tP)
XrdSsiSessReal(XrdSsiServReal *servP, const char *sName, int uent, bool hold=false)