|
xrootd
|
00001 #ifndef __FRCREQFILE_H__ 00002 #define __FRCREQFILE_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d F r c R e q F i l e . h h */ 00006 /* */ 00007 /* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 #include "XrdFrc/XrdFrcRequest.hh" 00014 #include "XrdSys/XrdSysPthread.hh" 00015 00016 class XrdFrcReqFile 00017 { 00018 public: 00019 00020 void Add(XrdFrcRequest *rP); 00021 00022 void Can(XrdFrcRequest *rP); 00023 00024 void Del(XrdFrcRequest *rP); 00025 00026 int Get(XrdFrcRequest *rP); 00027 00028 int Init(); 00029 00030 char *List(char *Buff, int bsz, int &Offs, 00031 XrdFrcRequest::Item *ITList=0, int ITNum=0); 00032 00033 void ListL(XrdFrcRequest &tmpReq, char *Buff, int bsz, 00034 XrdFrcRequest::Item *ITList, int ITNum); 00035 00036 XrdFrcReqFile(const char *fn, int aVal); 00037 ~XrdFrcReqFile() {} 00038 00039 private: 00040 enum LockType {lkNone, lkShare, lkExcl, lkInit}; 00041 00042 static const int ReqSize = sizeof(XrdFrcRequest); 00043 00044 void FailAdd(char *lfn, int unlk=1); 00045 void FailCan(char *rid, int unlk=1); 00046 void FailDel(char *lfn, int unlk=1); 00047 int FailIni(const char *lfn); 00048 int FileLock(LockType ltype=lkExcl); 00049 int reqRead(void *Buff, int Offs); 00050 int reqWrite(void *Buff, int Offs, int updthdr=1); 00051 00052 struct FileHdr 00053 { 00054 int First; 00055 int Last; 00056 int Free; 00057 } HdrData; 00058 00059 char *lokFN; 00060 int lokFD; 00061 int reqFD; 00062 char *reqFN; 00063 00064 int isAgent; 00065 00066 struct recEnt {recEnt *Next; 00067 XrdFrcRequest reqData; 00068 recEnt(XrdFrcRequest &reqref) {Next = 0; reqData = reqref;} 00069 }; 00070 int ReWrite(recEnt *rP); 00071 00072 class rqMonitor 00073 { 00074 public: 00075 rqMonitor(int isAgent) : doUL(isAgent) 00076 {if (isAgent) rqMutex.Lock();} 00077 ~rqMonitor() {if (doUL) rqMutex.UnLock();} 00078 private: 00079 static XrdSysMutex rqMutex; 00080 int doUL; 00081 }; 00082 }; 00083 #endif
1.7.5