Skip to content

Commit

Permalink
Improve readability of relinquish file process.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent ec1b207 commit 96b3cf7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -183,9 +183,12 @@ void Cache::Detach(XrdOucCacheIO* io)
while ( it != m_active.end() )
{
if (it->io == io) {
it->io->RelinquishFile(it->file);
delete it->file;
if (it->file) {
it->io->RelinquishFile(it->file);
delete it->file;
}
m_active.erase(it);
break;
}
else
++it;
Expand Down Expand Up @@ -304,9 +307,10 @@ File* Cache::GetFileWithLocalPath(std::string path, IO* iIo)
{
if (!strcmp(path.c_str(), it->file->lPath()))
{
it->io->RelinquishFile(it->file);
it->io = iIo;
return it->file;
File *ff = it->file;
it->io->RelinquishFile(ff);
it->file = 0;
return ff;
}
}
return 0;
Expand Down
8 changes: 3 additions & 5 deletions src/XrdFileCache/XrdFileCacheIOEntireFile.cc
Expand Up @@ -52,11 +52,9 @@ IOEntireFile::IOEntireFile(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache &
TRACEIO(Error, "IOEntireFile::IOEntireFile, could not get valid stat");

m_file = new File(io, fname, 0, st.st_size);
Cache::GetInstance().AddActive(this, m_file);
}
else {
// use system stat to init m_localStat if m_file is still in the map
}

Cache::GetInstance().AddActive(this, m_file);
}


Expand Down Expand Up @@ -138,7 +136,7 @@ int IOEntireFile::initCachedStat(const char* path)

bool IOEntireFile::ioActive()
{
if (!m_file)
if ( ! m_file)
return false;
else
return m_file->InitiateClose();
Expand Down

0 comments on commit 96b3cf7

Please sign in to comment.