00001 #ifndef __CMS_BASEFS_H__
00002 #define __CMS_BASEFS_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdlib.h>
00014 #include <string.h>
00015
00016 #include "XrdCms/XrdCmsPList.hh"
00017 #include "XrdCms/XrdCmsRRData.hh"
00018 #include "XrdCms/XrdCmsTypes.hh"
00019 #include "XrdOuc/XrdOucHash.hh"
00020 #include "XrdSys/XrdSysPthread.hh"
00021
00022
00023
00024
00025
00026 class XrdCmsPInfo;
00027
00028 class XrdCmsBaseFR
00029 {
00030 public:
00031
00032 SMask_t Route;
00033 SMask_t RouteW;
00034 XrdCmsBaseFR *Next;
00035 char *Buff;
00036 char *Path;
00037 short PathLen;
00038 short PDirLen;
00039 kXR_unt32 Sid;
00040 kXR_char Mod;
00041
00042 XrdCmsBaseFR(XrdCmsRRData &Arg, XrdCmsPInfo &Who, int Dln)
00043 : Route(Who.rovec), RouteW(Who.rwvec), Next(0),
00044 PathLen(Arg.PathLen), PDirLen(Dln),
00045 Sid(Arg.Request.streamid),
00046 Mod(Arg.Request.modifier)
00047 {if (Arg.Buff)
00048 {Path=Arg.Path; Buff=Arg.Buff; Arg.Buff=0;}
00049 else Buff = Path = strdup(Arg.Path);
00050 }
00051
00052 XrdCmsBaseFR(XrdCmsRRData *aP, XrdCmsPInfo &Who, int Dln)
00053 : Route(Who.rovec), RouteW(Who.rwvec),
00054 Next(0), Buff(0), Path(aP->Path),
00055 PathLen(aP->PathLen), PDirLen(Dln),
00056 Sid(aP->Request.streamid),
00057 Mod(aP->Request.modifier)
00058 {}
00059
00060 ~XrdCmsBaseFR() {if (Buff) free(Buff); Buff = 0;}
00061 };
00062
00063
00064
00065
00066
00067 class XrdCmsBaseFS
00068 {
00069 public:
00070
00071
00072
00073
00074
00075
00076
00077 int Exists(XrdCmsRRData &Arg,XrdCmsPInfo &Who,int noLim=0);
00078
00079
00080
00081
00082
00083
00084
00085
00086 int Exists(char *Path, int fnPos, int UpAT=0);
00087
00088
00089
00090 static const int Cntrl = 0x0001;
00091 static const int DFSys = 0x0002;
00092 static const int Immed = 0x0004;
00093 static const int Servr = 0x0100;
00094
00095 void Init(int Opts, int DMlife, int DPLife);
00096
00097 inline int isDFS() {return dfsSys;}
00098
00099 inline int Limit() {return theQ.rLimit;}
00100
00101 void Limit(int rLim, int qMax);
00102
00103 inline int Local() {return lclStat;}
00104
00105 void Pacer();
00106
00107 void Runner();
00108
00109 void Start();
00110
00111 inline int Trim() {return preSel;}
00112
00113 inline int Traverse() {return Punt;}
00114
00115 XrdCmsBaseFS(void (*theCB)(XrdCmsBaseFR *, int))
00116 : cBack(theCB), dmLife(0), dpLife(0), lclStat(0), preSel(1),
00117 dfsSys(0), Server(0), Fixed(0), Punt(0) {}
00118 ~XrdCmsBaseFS() {}
00119
00120 private:
00121
00122 struct dMoP {int Present;};
00123
00124 int Bypass();
00125 int FStat( char *Path, int fnPos, int upat=0);
00126 int hasDir(char *Path, int fnPos);
00127 void Queue(XrdCmsRRData &Arg, XrdCmsPInfo &Who,
00128 int dln, int Frc=0);
00129 void Xeq(XrdCmsBaseFR *rP);
00130
00131 XrdSysMutex fsMutex;
00132 XrdOucHash<dMoP> fsDirMP;
00133 void (*cBack)(XrdCmsBaseFR *, int);
00134
00135 struct RequestQ
00136 {XrdSysMutex Mutex;
00137 XrdSysSemaphore pqAvail;
00138 XrdSysSemaphore rqAvail;
00139 XrdCmsBaseFR *pqFirst;
00140 XrdCmsBaseFR *pqLast;
00141 XrdCmsBaseFR *rqFirst;
00142 XrdCmsBaseFR *rqLast;
00143 int rLimit;
00144 int qHWM;
00145 int qMax;
00146 int qNum;
00147 int rLeft;
00148 int rAgain;
00149 RequestQ() : pqAvail(0), rqAvail(0),
00150 pqFirst(0), pqLast(0), rqFirst(0), rqLast(0),
00151 rLimit(0), qHWM(0), qMax(1), qNum(0),
00152 rLeft(0), rAgain(0) {}
00153 ~RequestQ() {}
00154 } theQ;
00155
00156 int dmLife;
00157 int dpLife;
00158 char lclStat;
00159 char preSel;
00160 char dfsSys;
00161 char Server;
00162 char Fixed;
00163 char Punt;
00164 };
00165 namespace XrdCms
00166 {
00167 extern XrdCmsBaseFS baseFS;
00168 }
00169 #endif