Skip to content

Commit

Permalink
Corrections for partially implemented deferred open.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Mar 23, 2016
1 parent dc7c497 commit 090db98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
17 changes: 10 additions & 7 deletions src/XrdPosix/XrdPosixFile.cc
Expand Up @@ -225,22 +225,25 @@ bool XrdPosixFile::Close(XrdCl::XRootDStatus &Status)
/* F i n a l i z e */
/******************************************************************************/

bool XrdPosixFile::Finalize(XrdCl::XRootDStatus &Status)
bool XrdPosixFile::Finalize(XrdCl::XRootDStatus *Status)
{
XrdOucCacheIO2 *ioP;

// Indicate that we are at the start of the file
//
currOffset = 0;

// Complete initialization. If the stat() fails, the caller will unwind the
// whole open process (ick).
// whole open process (ick). In the process get correct I/O vector.

if (!Stat(Status))
return false;
if (!Status) ioP = (XrdOucCacheIO2 *)PrepIO;
else if (Stat(*Status)) ioP = (XrdOucCacheIO2 *)this;
else return false;

// Setup the cache if it is to be used
//
if (XrdPosixGlobals::theCache)
XCio = XrdPosixGlobals::theCache->Attach((XrdOucCacheIO2 *)this, cOpt);
XCio = XrdPosixGlobals::theCache->Attach(ioP, cOpt);

return true;
}
Expand All @@ -258,8 +261,8 @@ void XrdPosixFile::HandleResponse(XrdCl::XRootDStatus *status,

// If no errors occured, complete the open
//
if (!(status->IsOK())) rc = XrdPosixMap::Result(*status);
else if (!Finalize(Status)) rc = XrdPosixMap::Result(Status);
if (!(status->IsOK())) rc = XrdPosixMap::Result(*status);
else if (!Finalize(&Status)) rc = XrdPosixMap::Result(Status);

// Issue callback with the correct result
//
Expand Down
2 changes: 1 addition & 1 deletion src/XrdPosix/XrdPosixFile.hh
Expand Up @@ -84,7 +84,7 @@ static void DelayedDestroy(XrdPosixFile *fp);

bool Close(XrdCl::XRootDStatus &Status);

bool Finalize(XrdCl::XRootDStatus &Status);
bool Finalize(XrdCl::XRootDStatus *Status);

long long FSize() {AtomicBeg(updMutex);
long long retSize = AtomicGet(mySize);
Expand Down
8 changes: 6 additions & 2 deletions src/XrdPosix/XrdPosixXrootd.cc
Expand Up @@ -106,7 +106,11 @@ int OpenDefer(XrdPosixFile *fp,

// Allocate a prepare I/O object to defer this open
//
fp->XCio = fp->PrepIO = new XrdPosixPrepIO(fp, XOflags, XOmode);
fp->PrepIO = new XrdPosixPrepIO(fp, XOflags, XOmode);

// Finalize this file object. A null argument indicates it is defered.
//
fp->Finalize(0);

// For sync opens we just need to return the file descriptor
//
Expand Down Expand Up @@ -545,7 +549,7 @@ int XrdPosixXrootd::Open(const char *path, int oflags, mode_t mode,
// finalization is defered until the callback happens.
//
if (cbP) {errno = EINPROGRESS; return -1;}
if (fp->Finalize(Status)) return fp->FDNum();
if (fp->Finalize(&Status)) return fp->FDNum();
return XrdPosixMap::Result(Status);
}

Expand Down

0 comments on commit 090db98

Please sign in to comment.