XRootD
XrdXrootdFile Class Reference

#include <XrdXrootdFile.hh>

+ Collaboration diagram for XrdXrootdFile:

Public Member Functions

 XrdXrootdFile (const char *id, const char *path, XrdSfsFile *fp, char mode='r', bool async=false, struct stat *sP=0)
 
 ~XrdXrootdFile ()
 
void Ref (int num)
 
void Serialize ()
 

Static Public Member Functions

static void Init (XrdXrootdFileLock *lp, XrdSysError *erP, bool sfok)
 

Public Attributes

union {
unsigned long long cbArg
 
char * mmAddr
 
}; 
 
union {
int fdNum
 
int fHandle
 
}; 
 
XrdXrootdAioFobaioFob
 
bool AsyncMode
 
XrdXrootdFileHPfhProc
 
char * FileKey
 
char FileMode
 
const char * ID
 
bool isMMapped
 
XrdXrootdPgwFobpgwFob
 
bool sfEnabled
 
XrdXrootdFileStats Stats
 
XrdSfsFileXrdSfsp
 

Detailed Description

Definition at line 100 of file XrdXrootdFile.hh.

Constructor & Destructor Documentation

◆ XrdXrootdFile()

XrdXrootdFile::XrdXrootdFile ( const char *  id,
const char *  path,
XrdSfsFile fp,
char  mode = 'r',
bool  async = false,
struct stat sP = 0 
)

Definition at line 83 of file XrdXrootdFile.cc.

85  : XrdSfsp(fp), mmAddr(0), FileKey(strdup(path)),
86  FileMode(mode), AsyncMode(async),
87  aioFob(0), pgwFob(0), fhProc(0),
88  ID(id), refCount(0), syncWait(0)
89 {
90  static XrdSysMutex seqMutex;
91  struct stat buf;
92  off_t mmSize;
93 
94 // Initialize statistical counters
95 //
96  Stats.Init();
97 
98 // Get the file descriptor number for sendfile() processing
99 //
100  if (!sfOK || fp->fctl(SFS_FCTL_GETFD, 0, fp->error) != SFS_OK)
101  {fdNum = -1;
102  sfEnabled = false;
103  } else {
104  fdNum = fp->error.getErrInfo();
105  sfEnabled = (fdNum >= 0 || fdNum == (int)SFS_SFIO_FDVAL);
106  }
107 
108 // Determine if file is memory mapped
109 //
110  if (fp->getMmap((void **)&mmAddr, mmSize) != SFS_OK) isMMapped = false;
111  else {isMMapped = (mmSize ? true : false);
112  Stats.fSize = static_cast<long long>(mmSize);
113  }
114 
115 // Get file status information (we need it) and optionally return it to caller
116 //
117  if (sP || !isMMapped)
118  {if (!sP) sP = &buf;
119  fp->stat(sP);
120  if (!isMMapped) Stats.fSize = static_cast<long long>(sP->st_size);
121  }
122 }
int stat(const char *path, struct stat *buf)
#define SFS_SFIO_FDVAL
#define SFS_FCTL_GETFD
#define SFS_OK
XrdOucErrInfo & error
virtual int getMmap(void **Addr, off_t &Size)=0
virtual int stat(struct stat *buf)=0
virtual int fctl(const int cmd, const char *args, XrdOucErrInfo &eInfo)=0
const char * ID
XrdXrootdFileHP * fhProc
XrdXrootdPgwFob * pgwFob
XrdSfsFile * XrdSfsp
XrdXrootdAioFob * aioFob
XrdXrootdFileStats Stats

References XrdSfsFile::error, XrdSfsFile::fctl(), XrdXrootdFileStats::fSize, XrdOucErrInfo::getErrInfo(), XrdSfsFile::getMmap(), XrdXrootdFileStats::Init(), isMMapped, XrdXrootdMonInfo::seqMutex, sfEnabled, SFS_FCTL_GETFD, SFS_OK, SFS_SFIO_FDVAL, stat(), XrdSfsFile::stat(), and Stats.

+ Here is the call graph for this function:

◆ ~XrdXrootdFile()

XrdXrootdFile::~XrdXrootdFile ( )

Definition at line 139 of file XrdXrootdFile.cc.

140 {
141  if (aioFob) aioFob->Reset();
142 
143  Serialize(); // Make sure there are no outstanding references
144 
145  if (XrdSfsp)
146  {TRACEI(FS, "closing " <<FileMode <<' ' <<FileKey);
147  delete XrdSfsp;
148  XrdSfsp = 0;
149  Locker->Unlock(FileKey, FileMode);
150  }
151 
152  if (fhProc) fhProc->Avail(fHandle);
153 
154  if (aioFob) delete aioFob;
155 
156  if (pgwFob) delete pgwFob;
157 
158  if (FileKey) free(FileKey); // Must be the last thing deleted!
159 }
#define TRACEI(act, x)
Definition: XrdTrace.hh:66
void Avail(int fHandle)
virtual int Unlock(const char *path, char mode)=0

References aioFob, XrdXrootdFileHP::Avail(), fhProc, FileKey, FileMode, pgwFob, XrdXrootdAioFob::Reset(), Serialize(), TRACEI, XrdXrootdFileLock::Unlock(), and XrdSfsp.

+ Here is the call graph for this function:

Member Function Documentation

◆ Init()

void XrdXrootdFile::Init ( XrdXrootdFileLock lp,
XrdSysError erP,
bool  sfok 
)
static

Definition at line 128 of file XrdXrootdFile.cc.

129 {
130  Locker = lp;
131  eDest = erP;
132  sfOK = sfok;
133 }
static XrdSysError eDest(0,"crypto_")

References eDest.

Referenced by XrdXrootdProtocol::Configure().

+ Here is the caller graph for this function:

◆ Ref()

void XrdXrootdFile::Ref ( int  num)

Definition at line 165 of file XrdXrootdFile.cc.

166 {
167 
168 // Change the reference counter and check if anyone is waiting
169 //
170  fileMutex.Lock();
171  refCount += num;
172  TRACEI(FSAIO,"File::Ref="<<refCount<<" after +"<<num<<' '<<FileKey);
173  if (num < 0 && syncWait && refCount <= 0)
174  {syncWait->Post();
175  syncWait = nullptr;
176  }
177  fileMutex.UnLock();
178 }

References FileKey, XrdSysMutex::Lock(), XrdSysSemaphore::Post(), TRACEI, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Serialize()

void XrdXrootdFile::Serialize ( )

Definition at line 184 of file XrdXrootdFile.cc.

185 {
186 
187 // Wait until the reference count reaches zero
188 //
189  fileMutex.Lock();
190  TRACEI(FSAIO, "serializing access "<<FileMode<<" Ref="<<refCount<<' '<<FileKey);
191  if (refCount > 0)
192  {XrdSysSemaphore mySem(0);
193  syncWait = &mySem;
194  fileMutex.UnLock();
195  mySem.Wait();
196  } else fileMutex.UnLock();
197 }

References FileKey, FileMode, XrdSysMutex::Lock(), TRACEI, XrdSysMutex::UnLock(), and XrdSysSemaphore::Wait().

Referenced by ~XrdXrootdFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ 

union { ... }

◆ 

union { ... }

◆ aioFob

XrdXrootdAioFob* XrdXrootdFile::aioFob

Definition at line 117 of file XrdXrootdFile.hh.

Referenced by ~XrdXrootdFile().

◆ AsyncMode

bool XrdXrootdFile::AsyncMode

Definition at line 111 of file XrdXrootdFile.hh.

◆ fhProc

XrdXrootdFileHP* XrdXrootdFile::fhProc

Definition at line 119 of file XrdXrootdFile.hh.

Referenced by ~XrdXrootdFile().

◆ FileKey

char* XrdXrootdFile::FileKey

◆ FileMode

char XrdXrootdFile::FileMode

Definition at line 110 of file XrdXrootdFile.hh.

Referenced by ~XrdXrootdFile(), and Serialize().

◆ ID

const char* XrdXrootdFile::ID

Definition at line 120 of file XrdXrootdFile.hh.

◆ isMMapped

bool XrdXrootdFile::isMMapped

Definition at line 112 of file XrdXrootdFile.hh.

Referenced by XrdXrootdFile().

◆ pgwFob

XrdXrootdPgwFob* XrdXrootdFile::pgwFob

Definition at line 118 of file XrdXrootdFile.hh.

Referenced by ~XrdXrootdFile(), and XrdXrootdPgwBadCS::boAdd().

◆ sfEnabled

bool XrdXrootdFile::sfEnabled

◆ Stats

XrdXrootdFileStats XrdXrootdFile::Stats

◆ XrdSfsp

XrdSfsFile* XrdXrootdFile::XrdSfsp

Definition at line 104 of file XrdXrootdFile.hh.

Referenced by ~XrdXrootdFile(), and XrdXrootdProtocol::do_WriteSpan().


The documentation for this class was generated from the following files: