00001 #ifndef __SSI_FILESESS_H__
00002 #define __SSI_FILESESS_H__
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 #include <sys/types.h>
00034
00035 #include "XrdSfs/XrdSfsInterface.hh"
00036 #include "XrdSsi/XrdSsiBVec.hh"
00037 #include "XrdSsi/XrdSsiFileReq.hh"
00038 #include "XrdSsi/XrdSsiFileResource.hh"
00039 #include "XrdSsi/XrdSsiRRTable.hh"
00040 #include "XrdSys/XrdSysPthread.hh"
00041
00042 class XrdOucEnv;
00043 class XrdSfsXioHandle;
00044 struct XrdSsiRespInfo;
00045
00046 class XrdSsiFileSess
00047 {
00048 public:
00049
00050 static XrdSsiFileSess *Alloc(XrdOucErrInfo &einfo, const char *user);
00051
00052 bool AttnInfo( XrdOucErrInfo &eInfo,
00053 const XrdSsiRespInfo *respP,
00054 unsigned int reqID);
00055
00056 XrdOucErrInfo *errInfo() {return eInfo;}
00057
00058 int close(bool viaDel=false);
00059
00060 int fctl(const int cmd,
00061 int alen,
00062 const char *args,
00063 const XrdSecEntity *client);
00064
00065 const char *FName() {return gigID;}
00066
00067 int open(const char *fileName,
00068 XrdOucEnv &theEnv,
00069 XrdSfsFileOpenMode openMode);
00070
00071 XrdSfsXferSize read(XrdSfsFileOffset fileOffset,
00072 char *buffer,
00073 XrdSfsXferSize buffer_size);
00074
00075 void Recycle();
00076
00077 XrdSsiFileResource &Resource() {return fileResource;}
00078
00079 int SendData(XrdSfsDio *sfDio,
00080 XrdSfsFileOffset offset,
00081 XrdSfsXferSize size);
00082
00083 static void SetAuthDNS() {authDNS = true;}
00084
00085 static void SetMaxSz(int mSz) {maxRSZ = mSz;}
00086
00087 void setXio(XrdSfsXio *xP) {xioP = xP;}
00088
00089 int truncate(XrdSfsFileOffset fileOffset);
00090
00091 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00092 const char *buffer,
00093 XrdSfsXferSize buffer_size);
00094
00095 private:
00096
00097
00098
00099 XrdSsiFileSess(XrdOucErrInfo &einfo, const char *user)
00100 {Init(einfo, user, false);}
00101 ~XrdSsiFileSess() {}
00102
00103 void Init(XrdOucErrInfo &einfo, const char *user, bool forReuse);
00104 bool NewRequest(unsigned int reqid, XrdOucBuffer *oP,
00105 XrdSfsXioHandle *bR, int rSz);
00106 void Reset();
00107 XrdSfsXferSize writeAdd(const char *buff, XrdSfsXferSize blen,
00108 unsigned int rid);
00109
00110 static XrdSysMutex arMutex;
00111 static XrdSsiFileSess *freeList;
00112 static int freeNum;
00113 static int freeNew;
00114 static int freeMax;
00115 static int freeAbs;
00116
00117 static int maxRSZ;
00118 static bool authDNS;
00119
00120 XrdSsiFileResource fileResource;
00121 char *tident;
00122 XrdOucErrInfo *eInfo;
00123 char *gigID;
00124 char *fsUser;
00125 XrdSysMutex myMutex;
00126 XrdSfsXio *xioP;
00127 XrdOucBuffer *oucBuff;
00128 XrdSsiFileSess *nextFree;
00129 int reqSize;
00130 int reqLeft;
00131 bool isOpen;
00132 bool inProg;
00133
00134 XrdSsiBVec eofVec;
00135 XrdSsiRRTable<XrdSsiFileReq> rTab;
00136 };
00137 #endif