Skip to content

Commit

Permalink
Delete disk syncer in destructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent 3220cb2 commit adcf932
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions src/XrdFileCache/XrdFileCacheFile.cc
Expand Up @@ -88,7 +88,6 @@ m_prefetchState(kOn),
m_prefetchReadCnt(0),
m_prefetchHitCnt(0),
m_prefetchScore(1),
m_prefetchCurrentCnt(0),
m_traceID("File")
{
Open();
Expand Down Expand Up @@ -116,6 +115,9 @@ File::~File()
AppendIOStatToFileInfo();
m_infoFile->Fsync();

delete m_syncer;
m_syncer = NULL;

if (m_output)
{
m_output->Close();
Expand Down Expand Up @@ -147,48 +149,40 @@ bool File::ioActive()
m_stateCond.UnLock();

m_stateCond.Lock();
bool isPrefetching = (m_prefetchCurrentCnt > 0);
m_stateCond.UnLock();

if (isPrefetching == false)
{
m_downloadCond.Lock();

/*
// dump print
for (BlockMap_i it = m_block_map.begin(); it != m_block_map.end(); ++it) {
Block* b = it->second;
TRACEF(Dump, "File::InitiateClose() block idx = " << b->m_offset/m_cfi.GetBufferSize() << " prefetch = " << b->preferch << " refcnt " << b->refcnt);
m_downloadCond.Lock();
/*
// high debug print
for (BlockMap_i it = m_block_map.begin(); it != m_block_map.end(); ++it) {
Block* b = it->second;
TRACEF(Dump, "File::InitiateClose() block idx = " << b->m_offset/m_cfi.GetBufferSize() << " prefetch = " << b->preferch << " refcnt " << b->refcnt);
}
*/
// remove failed blocks
BlockMap_i itr = m_block_map.begin();
while (itr != m_block_map.end()) {
if (itr->second->is_failed() && itr->second->m_refcnt == 1) {
BlockMap_i toErase = itr;
++itr;
TRACEF(Debug, "Remove failed block " << itr->second->m_offset/m_cfi.GetBufferSize());
free_block(toErase->second);
}
*/

// remove failed blocks
BlockMap_i itr = m_block_map.begin();
while (itr != m_block_map.end()) {
if (itr->second->is_failed() && itr->second->m_refcnt == 1) {
BlockMap_i toErase = itr;
++itr;
TRACEF(Debug, "Remove failed block " << itr->second->m_offset/m_cfi.GetBufferSize());
free_block(toErase->second);
}
else {
++itr;
}
else {
++itr;
}
}

bool blockMapEmpty = m_block_map.empty();
m_downloadCond.UnLock();
bool blockMapEmpty = m_block_map.empty();
m_downloadCond.UnLock();

if ( blockMapEmpty)
{
// file is not active when block map is empty and sync is done
XrdSysMutexHelper _lck(&m_syncStatusMutex);
if (m_in_sync == false) {
delete m_syncer;
m_syncer = NULL;
return false;
}
if ( blockMapEmpty)
{
// file is not active when block map is empty and sync is done
XrdSysMutexHelper _lck(&m_syncStatusMutex);
if (m_in_sync == false) {
return false;
}
}

Expand Down

0 comments on commit adcf932

Please sign in to comment.