XrdXrootdFile.hh

Go to the documentation of this file.
00001 #ifndef _XROOTD_FILE_H_
00002 #define _XROOTD_FILE_H_
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                      X r d X r o o t d F i l e . h h                       */
00006 /*                                                                            */
00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00010 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //       $Id: XrdXrootdFile.hh 26376 2008-11-22 11:07:11Z ganis $
00014 
00015 #include <string.h>
00016 
00017 #include "XProtocol/XPtypes.hh"
00018 
00019 /******************************************************************************/
00020 /*                              x r d _ F i l e                               */
00021 /******************************************************************************/
00022 
00023 class XrdSfsFile;
00024 class XrdXrootdFileLock;
00025 
00026 class XrdXrootdFile
00027 {
00028 public:
00029 
00030 XrdSfsFile  *XrdSfsp;           // -> Actual file object
00031 char        *mmAddr;            // Memory mapped location, if any
00032 long long    fSize;             // File size at time of object creation
00033 int          fdNum;             // File descriptor number if regular file
00034 kXR_unt32    FileID;            // Unique file id used for monitoring
00035 char         FileKey[34];       // -> Unique hash name for the file
00036 char         Reserved[2];
00037 char         FileMode;          // 'r' or 'w'
00038 char         AsyncMode;         // 1 -> if file in async r/w mode
00039 char         isMMapped;         // 1 -> file is memory mapped
00040 char         sfEnabled;         // 1 -> file is sendfile enabled
00041 char        *ID;                // File user
00042 long long    readCnt;
00043 long long    writeCnt;
00044 
00045 static void Init(XrdXrootdFileLock *lp, int sfok) {Locker = lp; sfOK = sfok;}
00046 
00047            XrdXrootdFile(char *id, XrdSfsFile *fp, char mode='r', 
00048                          char async='\0', int sfOK=0, struct stat *sP=0);
00049           ~XrdXrootdFile();
00050 
00051 private:
00052 int bin2hex(char *outbuff, char *inbuff, int inlen);
00053 static XrdXrootdFileLock *Locker;
00054 static int                sfOK;
00055 static const char        *TraceID;
00056 };
00057  
00058 /******************************************************************************/
00059 /*                      x r o o t d _ F i l e T a b l e                       */
00060 /******************************************************************************/
00061 
00062 // The before define the structure of the file table. We will have FTABSIZE
00063 // internal table entries. We will then provide an external linear table
00064 // that increases by FTABSIZE entries. There is one file table per link and
00065 // it is owned by the base protocol object.
00066 //
00067 #define XRD_FTABSIZE   16
00068   
00069 // WARNING! Manipulation (i.e., Add/Del/delete) of this object must be
00070 //          externally serialized at the link level. Only one thread
00071 //          may be active w.r.t this object during manipulation!
00072 //
00073 class XrdXrootdFileTable
00074 {
00075 public:
00076 
00077        int            Add(XrdXrootdFile *fp);
00078 
00079        void           Del(int fnum);
00080 
00081 inline XrdXrootdFile *Get(int fnum)
00082                          {if (fnum >= 0)
00083                              {if (fnum < XRD_FTABSIZE) return FTab[fnum];
00084                               if (XTab && (fnum-XRD_FTABSIZE)<XTnum)
00085                                  return XTab[fnum-XRD_FTABSIZE];
00086                              }
00087                           return (XrdXrootdFile *)0;
00088                          }
00089 
00090        XrdXrootdFileTable() {memset((void *)FTab, 0, sizeof(FTab));
00091                              FTfree = 0; XTab = 0; XTnum = XTfree = 0;
00092                             }
00093       ~XrdXrootdFileTable();
00094 
00095 private:
00096 
00097 static const char *TraceID;
00098 
00099 XrdXrootdFile *FTab[XRD_FTABSIZE];
00100 int            FTfree;
00101 
00102 XrdXrootdFile **XTab;
00103 int             XTnum;
00104 int             XTfree;
00105 };
00106 #endif

Generated on Tue Jul 5 14:47:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1