00001 #ifndef __XRDSSISESSREAL_HH__
00002 #define __XRDSSISESSREAL_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <string.h>
00033
00034 #include "XrdCl/XrdClFile.hh"
00035
00036 #include "XrdSsi/XrdSsiAtomics.hh"
00037 #include "XrdSsi/XrdSsiEvent.hh"
00038
00039 #include "XrdSys/XrdSysPthread.hh"
00040
00041 class XrdSsiServReal;
00042 class XrdSsiTaskReal;
00043
00044 class XrdSsiSessReal : public XrdSsiEvent
00045 {
00046 public:
00047
00048 XrdSsiSessReal *nextSess;
00049
00050 const char *GetKey() {return resKey;}
00051
00052 uint32_t GetSID() {return sessID;}
00053
00054 void InitSession(XrdSsiServReal *servP,
00055 const char *sName,
00056 int uent,
00057 bool hold,
00058 bool newSID=false);
00059
00060 void Lock() {sessMutex.Lock();}
00061
00062 XrdSsiMutex *MutexP() {return &sessMutex;}
00063
00064 bool Provision(XrdSsiRequest *reqP, const char *epURL);
00065
00066 bool Run(XrdSsiRequest *reqP);
00067
00068 void SetKey(const char *key)
00069 {if (resKey) free(resKey);
00070 resKey = (key ? strdup(key) : 0);
00071 }
00072
00073 void TaskFinished(XrdSsiTaskReal *tP);
00074
00075 void UnHold(bool cleanup=true);
00076
00077 void UnLock() {sessMutex.UnLock();}
00078
00079 void Unprovision();
00080
00081 bool XeqEvent(XrdCl::XRootDStatus *status,
00082 XrdCl::AnyObject **respP);
00083
00084 XrdSsiSessReal(XrdSsiServReal *servP,
00085 const char *sName,
00086 int uent,
00087 bool hold=false)
00088 : sessMutex(XrdSsiMutex::Recursive),
00089 resKey(0), sessName(0), sessNode(0)
00090 {InitSession(servP, sName, uent, hold, true);}
00091
00092 ~XrdSsiSessReal();
00093
00094 XrdCl::File epFile;
00095
00096 private:
00097 XrdSsiTaskReal *NewTask(XrdSsiRequest *reqP);
00098 void RelTask(XrdSsiTaskReal *tP);
00099 void Shutdown(XrdCl::XRootDStatus &epStatus, bool onClose);
00100
00101 XrdSsiMutex sessMutex;
00102 XrdSsiServReal *myService;
00103 XrdSsiTaskReal *attBase;
00104 XrdSsiTaskReal *freeTask;
00105 XrdSsiRequest *requestP;
00106 char *resKey;
00107 char *sessName;
00108 char *sessNode;
00109 uint32_t sessID;
00110 uint32_t nextTID;
00111 uint32_t alocLeft;
00112 int16_t uEnt;
00113 bool isHeld;
00114 bool inOpen;
00115 bool noReuse;
00116 };
00117 #endif