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 "XrdSfs/XrdSfsXio.hh"
00037 #include "XrdSsi/XrdSsiBVec.hh"
00038 #include "XrdSsi/XrdSsiFileReq.hh"
00039 #include "XrdSsi/XrdSsiFileResource.hh"
00040 #include "XrdSsi/XrdSsiRRTable.hh"
00041 #include "XrdSys/XrdSysPthread.hh"
00042
00043 class XrdOucEnv;
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 void setXio(XrdSfsXio *xP) {xioP = xP;}
00086
00087 int truncate(XrdSfsFileOffset fileOffset);
00088
00089 XrdSfsXferSize write(XrdSfsFileOffset fileOffset,
00090 const char *buffer,
00091 XrdSfsXferSize buffer_size);
00092
00093 private:
00094
00095
00096
00097 XrdSsiFileSess(XrdOucErrInfo &einfo, const char *user)
00098 {Init(einfo, user, false);}
00099 ~XrdSsiFileSess() {}
00100
00101 void Init(XrdOucErrInfo &einfo, const char *user, bool forReuse);
00102 bool NewRequest(unsigned int reqid, XrdOucBuffer *oP,
00103 XrdSfsXioHandle bR, int rSz);
00104 void Reset();
00105 XrdSfsXferSize writeAdd(const char *buff, XrdSfsXferSize blen,
00106 unsigned int rid);
00107
00108 static XrdSysMutex arMutex;
00109 static XrdSsiFileSess *freeList;
00110 static int freeNum;
00111 static int freeNew;
00112 static int freeMax;
00113 static int freeAbs;
00114 static bool authDNS;
00115
00116 XrdSsiFileResource fileResource;
00117 char *tident;
00118 XrdOucErrInfo *eInfo;
00119 char *gigID;
00120 char *fsUser;
00121 XrdSysMutex myMutex;
00122 XrdSfsXio *xioP;
00123 XrdOucBuffer *oucBuff;
00124 XrdSsiFileSess *nextFree;
00125 int reqSize;
00126 int reqLeft;
00127 bool isOpen;
00128 bool inProg;
00129
00130 XrdSsiBVec eofVec;
00131 XrdSsiRRTable<XrdSsiFileReq> rTab;
00132 };
00133 #endif