Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pfc-V2: Fix crash File destructor #353

Merged
merged 2 commits into from
Apr 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 20 additions & 23 deletions src/XrdFileCache/XrdFileCacheFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@ File::~File()
clLog()->Debug(XrdCl::AppMsg, "File::~File() enter %p %s", (void*)this, lPath());


// Wait disk sync
bool do_sync = false;
{
XrdSysMutexHelper _lck(&m_syncStatusMutex);
if (m_non_flushed_cnt > 0 || !m_writes_during_sync.empty())
{
do_sync = true;
m_in_sync = true;
clLog()->Info(XrdCl::AppMsg, "File::~File sync unflushed %d\n", m_non_flushed_cnt);
}
}
if (do_sync)
{
Sync();
}
// write statistics in *cinfo file
AppendIOStatToFileInfo();

Expand All @@ -142,7 +127,11 @@ File::~File()
delete m_infoFile;
m_infoFile = NULL;
}
delete m_syncer;

m_syncStatusMutex.Lock();
bool syncEmpty = m_writes_during_sync.empty();
m_syncStatusMutex.UnLock();
if (!syncEmpty) Sync();

// print just for curiosity
clLog()->Debug(XrdCl::AppMsg, "File::~File() ended, prefetch score ...%d/%d=%.2f", m_prefetchHitCnt, m_prefetchReadCnt, m_prefetchScore);
Expand Down Expand Up @@ -192,7 +181,15 @@ bool File::InitiateClose()
m_downloadCond.UnLock();

if ( blockMapEmpty)
return false;
{
// 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;
}
}
}

return true;
Expand Down Expand Up @@ -724,13 +721,13 @@ void File::WriteBlockToDisk(Block* b)
{
m_cfi.SetBitWriteCalled(pfIdx);
++m_non_flushed_cnt;
}
if (m_non_flushed_cnt >= 100 )
{
schedule_sync = true;
m_in_sync = true;
m_non_flushed_cnt = 0;
}

if (m_non_flushed_cnt >= 100 )
{
schedule_sync = true;
m_in_sync = true;
m_non_flushed_cnt = 0;
}
}

Expand Down