34 #include <netinet/in.h>
35 #include <sys/types.h>
47 #define TRACELINK this
60 int XrdXrootdFile::sfOK = 1;
61 const char *XrdXrootdFile::TraceID =
"File";
62 const char *XrdXrootdFileTable::TraceID =
"FileTable";
63 const char *XrdXrootdFileTable::ID =
"";
71 static const unsigned long heldSpotV = 1UL;;
73 static const unsigned long heldMask = ~1UL;
84 char mode,
bool async,
struct stat *sP)
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)
111 else {
isMMapped = (mmSize ? true :
false);
172 TRACEI(FSAIO,
"File::Ref="<<refCount<<
" after +"<<num<<
' '<<
FileKey);
173 if (num < 0 && syncWait && refCount <= 0)
196 }
else fileMutex.
UnLock();
215 if (fhProc && (i = fhProc->
Get()) >= 0)
219 if (XTab && i < XTnum) fP = &XTab[i];
229 snprintf(fhn,
sizeof(fhn),
"%d", i);
230 eDest->
Emsg(
"FTab_Add",
"Invalid recycled fHandle",fhn,
"ignored.");
235 for (i = FTfree; i <
XRD_FTABSIZE; i++)
if (!FTab[i])
break;
238 {FTab[i] = fp; FTfree = i+1;
return i;}
244 memset((
void *)XTab, 0, allocsz);
253 for (i = XTfree; i < XTnum; i++)
if (!XTab[i])
break;
261 memcpy((
void *)newXTab, (
const void *)XTab, XTnum*
sizeof(
XrdXrootdFile *));
262 memset((
void *)(newXTab+XTnum), 0, allocsz);
287 if (fnum < FTfree) FTfree = fnum;
290 if (XTab && fnum < XTnum)
293 if (fnum < XTfree) XTfree = fnum;
314 if (dodel) {
delete fp; fp = 0;}
319 TRACEI(FS,
"defer fh " <<fh <<
" del for " <<fp->FileKey);
347 delete FTab[i]; FTab[i] = 0;
353 {
for (i = 0; i < XTnum; i++)
363 free(XTab); XTab = 0; XTnum = 0; XTfree = 0;
369 if (fhProc) fhProc->
Delete();
383 int XrdXrootdFile::bin2hex(
char *outbuff,
char *inbuff,
int inlen)
385 static char hv[] =
"0123456789abcdef";
390 for (i = 0; i < inlen; i++)
if (inbuff[i])
break;
392 {outbuff[0] =
'0'; outbuff[1] =
'\0';
return 1;}
396 for ( ; i < inlen; i++)
397 {outbuff[j++] = hv[(inbuff[i] >> 4) & 0x0f];
398 outbuff[j++] = hv[ inbuff[i] & 0x0f];
static XrdSysError eDest(0,"crypto_")
int stat(const char *path, struct stat *buf)
XrdSysTrace XrdXrootdTrace
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
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
virtual int Unlock(const char *path, char mode)=0
void Recycle(XrdXrootdMonitor *monP)
int Add(XrdXrootdFile *fp)
static XrdXrootdFile * heldSpotP
XrdXrootdFile * Del(XrdXrootdMonitor *monP, int fnum, bool dodel=true)
XrdXrootdFile(const char *id, const char *path, XrdSfsFile *fp, char mode='r', bool async=false, struct stat *sP=0)
static void Init(XrdXrootdFileLock *lp, XrdSysError *erP, bool sfok)
static void Close(XrdXrootdFileStats *fsP, bool isDisc=false)
void Close(kXR_unt32 dictid, long long rTot, long long wTot)