36#include <sys/resource.h>
79std::string dsProperty(
"DataServer");
103 {rc = result; pgSem.Post();}
105int Wait4PGIO() {pgSem.Wait();
return rc;}
107 pgioCB(
const char *who) : pgSem(0, who), rc(0) {}
112XrdSysSemaphore pgSem;
126 isStream(Opts &
isStrm ? 1 : 0)
131 fOpen = strdup(path); aOK =
true;
134 else if (!fPath) fPath = fOpen;
139 {
int n = strlen(path);
170 if (fPath) free(fPath);
171 if (fOpen != fPath) free(fOpen);
172 if (fLoc) free(fLoc);
189 std::string statusMsg;
192 char buff[512], buff2[256];
193 static int ddNumLost = 0;
216 DEBUG(
"DLY destroy of "<<ddCount<<
" objects; "<<ddNumLost <<
" already lost.");
221 int nowLost = ddNumLost;
222 while((fCurr = fNext))
223 {fNext = fCurr->nextFile;
224 if (!(refNum = fCurr->
Refs()))
226 {
delete fCurr; ddCount--;
continue;}
227 else {statusMsg = Status.
ToString();
228 eTxt = statusMsg.c_str();
233 {ddNumLost++; ddCount--;
235 {snprintf(buff2,
sizeof(buff2),
"in use %d", refNum);
239 {snprintf(buff,
sizeof(buff),
"%s timeout closing", eTxt);
243 <<
' ' <<ddNumLost <<
" objects lost");
256 if (
Say && ddNumLost - nowLost >= 3)
257 {snprintf(buff,
sizeof(buff),
"%d objects deferred and %d lost.",
259 Say->Emsg(
"DDestroy", buff);
261 DEBUG(
"DLY destroy end; "<<ddCount<<
" objects deferred and "
262 <<ddNumLost <<
" lost.");
300 DEBUG(
"DLY destroy " << (doPost ?
"post " :
"has ") << ddCount
303 if (doPost)
ddSem.Post();
324 if (Status.
IsOK())
return true;
373 theSize =
XCio->FSize();
374 if (theSize < 0)
return static_cast<int>(theSize);
379 buf.st_size = theSize;
383 buf.st_blocks = buf.st_size/512 + buf.st_size%512;
418 if (rc < 0)
delete this;
430 if (!
clFile.IsOpen())
return "";
434 if (!fLoc || refresh)
435 {std::string currNode;
436 if (
clFile.GetProperty(dsProperty, currNode))
437 {
if (!fLoc || strcmp(fLoc, currNode.c_str()))
438 {
if (fLoc) free(fLoc);
439 fLoc = strdup(currNode.c_str());
456 std::vector<uint32_t> &csvec,
462 pgioCB pgrCB(
"Posix pgRead CB");
463 pgRead(pgrCB, buff, offs, rlen, csvec,
opts, csfix);
464 return pgrCB.Wait4PGIO();
473 std::vector<uint32_t> &csvec,
487 if (csfix) *csfix = 0;
493 Status =
clFile.PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
510 std::vector<uint32_t> &csvec,
518 if (csfix) *csfix = 0;
523 Status =
clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec);
535 std::vector<uint32_t> &csvec,
557 Status =
clFile.PgWrite((uint64_t)offs, (uint32_t)wlen, buff, csvec, rhP);
579 {pgioCB pgrCB(
"Posix pgRead CB");
580 Read(pgrCB, Buff, Offs, Len);
581 return pgrCB.Wait4PGIO();
587 Status =
clFile.Read((uint64_t)Offs, (uint32_t)Len, Buff, bytes);
611 if (doPgRd) Status =
clFile.PgRead((uint64_t)offs,(uint32_t)rlen,buff,rhP);
612 else Status =
clFile.Read ((uint64_t)offs,(uint32_t)rlen,buff,rhP);
636 for (
int i = 0; i < n; i++)
637 {nbytes += readV[i].
size;
639 (uint32_t)readV[i].size,
640 (
void *)readV[i].data
648 Status =
clFile.VectorRead(chunkVec, (
void *)0, vrInfo);
668 for (
int i = 0; i < n; i++)
669 {nbytes += readV[i].
size;
671 (uint32_t)readV[i].size,
672 (
void *)readV[i].data
681 Status =
clFile.VectorRead(chunkVec, (
void *)0, rhp);
702 Status =
clFile.Stat(force, sInfo);
715 myInode =
static_cast<ino_t
>(strtoll(sInfo->
GetId().c_str(), 0, 10));
763 Status =
clFile.Sync(rhp);
800 Status =
clFile.Write((uint64_t)Offs, (uint32_t)Len, Buff);
818 Status =
clFile.Write((uint64_t)offs, (uint32_t)wlen, buff, rhp);
XrdOucPup XrdCmsParser::Pup & Say
std::string obfuscateAuth(const std::string &input)
bool IsOpen() const
Check if the file is open.
uint64_t GetChangeTime() const
Get change time (in seconds since epoch)
uint64_t GetSize() const
Get size (in bytes)
uint32_t GetFlags() const
Get flags.
bool ExtendedFormat() const
Has extended stat information.
const std::string & GetId() const
Get id.
uint64_t GetModTime() const
Get modification time (in seconds since epoch)
uint64_t GetAccessTime() const
Get change time (in seconds since epoch)
static const uint64_t forceCS
XrdOucCacheIO()
Construct and Destructor.
static const int optRW
File is read/write (o/w read/only)
static const int optFIS
File is structured (e.g. root file)
An abstract class to define a callback for Open() call.
virtual void Complete(int Result)=0
static void initStat(struct stat *buf)
void setCSVec(std::vector< uint32_t > *csv, int *csf, bool fcs=false)
static XrdPosixFileRH * Alloc(XrdOucCacheIOCB *cbp, XrdPosixFile *fp, long long offs, int xResult, ioType typeIO)
XrdPosixFile(bool &aOK, const char *path, XrdPosixCallBack *cbP=0, int Opts=0)
static XrdSysSemaphore ddSem
static XrdSysMutex ddMutex
int Write(char *Buff, long long Offs, int Len) override
static XrdPosixFile * ddLost
int Read(char *Buff, long long Offs, int Len) override
int Fstat(struct stat &buf) override
int pgRead(char *buff, long long offs, int rdlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0) override
int Trunc(long long Offset) override
const char * Location(bool refresh=false) override
bool Stat(XrdCl::XRootDStatus &Status, bool force=false)
bool Close(XrdCl::XRootDStatus &Status)
static XrdPosixFile * ddList
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
bool Finalize(XrdCl::XRootDStatus *Status)
int ReadV(const XrdOucIOVec *readV, int n) override
static void * DelayedDestroy(void *)
int pgWrite(char *buff, long long offs, int wrlen, std::vector< uint32_t > &csvec, uint64_t opts=0, int *csfix=0) override
static mode_t Flags2Mode(dev_t *rdv, uint32_t flags)
static int Result(const XrdCl::XRootDStatus &Status, XrdOucECMsg &ecMsg, bool retneg1=false)
static const char * P2L(const char *who, const char *inP, char *&relP, bool ponly=false)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)
static void Snooze(int seconds)
std::vector< ChunkInfo > ChunkList
List of chunks.
Describe a data chunk for vector read.
bool IsOK() const
We're fine.
std::string ToString() const
Create a string representation.