xrootd
|
00001 #ifndef __XRDCnsLogFile_H_ 00002 #define __XRDCnsLogFile_H_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d C n s L o g F i l e . h h */ 00006 /* */ 00007 /* (c) 2009 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 // $Id$ 00014 00015 #include "XrdCns/XrdCnsLogRec.hh" 00016 #include "XrdSys/XrdSysPthread.hh" 00017 00018 class XrdCnsLogFile 00019 { 00020 public: 00021 00022 XrdCnsLogFile *Next; 00023 00024 int Add(XrdCnsLogRec *Rec, int doSync=1); 00025 00026 int Commit(); 00027 00028 int Eol(); 00029 00030 const char *FName() {return logFN;} 00031 00032 char *getLog(int &Dlen) {Dlen = logNext-logBuff; return logBuff;} 00033 00034 XrdCnsLogRec *getRec(); 00035 00036 static void maxRecs(int nRecs) {logRMax = nRecs; 00037 logBMax = nRecs * sizeof(XrdCnsLogRec); 00038 } 00039 00040 int Open(int aBuff=1, off_t thePos=0); 00041 00042 XrdCnsLogFile *Subscribe(const char *Path, int cNum); 00043 00044 int Unlink(); 00045 00046 XrdCnsLogFile(const char *Path, int cnum=0, int Wait=1) 00047 : Next(0), logSem(0), subNext(0), 00048 logBuff(0),logNext(0), logFN(strdup(Path)), 00049 logFD(-1), logRdr(cnum), logWait(Wait), 00050 logOffset(0), recOffset(0) {} 00051 ~XrdCnsLogFile(); 00052 00053 private: 00054 int Read(char *buff, int blen); 00055 00056 static int logRMax; 00057 static int logBMax; 00058 00059 XrdSysMutex logMutex; 00060 XrdSysSemaphore logSem; 00061 XrdSysSemaphore synSem; 00062 XrdCnsLogFile *subNext; 00063 00064 XrdCnsLogRec Rec; 00065 00066 char *logBuff; 00067 char *logNext; 00068 00069 char *logFN; 00070 int logFD; 00071 int logRdr; 00072 int logWait; 00073 int logOffset; 00074 int recOffset; 00075 }; 00076 #endif