Skip to content

Commit

Permalink
Use m_downloadCond for sync status.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja committed Jul 27, 2016
1 parent ea23cfa commit 87ceabb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/XrdFileCache/XrdFileCacheFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ File::~File()
{
if (m_infoFile)
{
m_syncStatusMutex.Lock();
m_downloadCond.Lock();
bool need_sync = (!m_writes_during_sync.empty()) || m_non_flushed_cnt > 0;
m_syncStatusMutex.UnLock();
m_downloadCond.UnLock();
if (need_sync)
Sync();

Expand Down Expand Up @@ -186,7 +186,7 @@ bool File::ioActive()
if (blockMapEmpty)
{
// file is not active when block map is empty and sync is done
XrdSysMutexHelper _lck(&m_syncStatusMutex);
XrdSysCondVarHelper _lck(&m_downloadCond);
if ( ! m_in_sync)
{
m_in_sync = true;
Expand Down Expand Up @@ -717,19 +717,16 @@ void File::WriteBlockToDisk(Block* b)
TRACEF(Dump, "File::WriteToDisk() success set bit for block " << b->m_offset << " size " << size);
int pfIdx = (b->m_offset - m_offset)/m_cfi.GetBufferSize();

bool schedule_sync = false;
{
XrdSysCondVarHelper _lck(m_downloadCond);

m_cfi.SetBitWritten(pfIdx);
// clLog()->Dump(XrdCl::AppMsg, "File::WriteToDisk() dec_ref_count %d %s", pfIdx, lPath());
dec_ref_count(b);
}

// set bit synced
bool schedule_sync = false;
{
XrdSysMutexHelper _lck(&m_syncStatusMutex);

// set bit synced
if (m_in_sync)
{
m_writes_during_sync.push_back(pfIdx);
Expand Down Expand Up @@ -765,7 +762,7 @@ void File::Sync()

int written_while_in_sync;
{
XrdSysMutexHelper _lck(&m_syncStatusMutex);
XrdSysCondVarHelper _lck(&m_downloadCond);
for (std::vector<int>::iterator i = m_writes_during_sync.begin(); i != m_writes_during_sync.end(); ++i)
{
m_cfi.SetBitSynced(*i);
Expand Down
1 change: 0 additions & 1 deletion src/XrdFileCache/XrdFileCacheFile.hh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ namespace XrdFileCache
XrdSysCondVar m_prefetchStateCond; //!< state condition variable

// fsync
XrdSysMutex m_syncStatusMutex; //!< mutex locking fsync status
XrdJob *m_syncer;
std::vector<int> m_writes_during_sync;
int m_non_flushed_cnt;
Expand Down

0 comments on commit 87ceabb

Please sign in to comment.