diff --git a/src/XrdFileCache/XrdFileCacheFile.cc b/src/XrdFileCache/XrdFileCacheFile.cc index 262e72f3bdf..bef067d6274 100644 --- a/src/XrdFileCache/XrdFileCacheFile.cc +++ b/src/XrdFileCache/XrdFileCacheFile.cc @@ -146,11 +146,11 @@ bool File::ioActive() m_prefetchState = kStopped; cache()->DeRegisterPrefetchFile(this); } - m_stateCond.UnLock(); - m_stateCond.Lock(); m_stateCond.UnLock(); + + // remove failed blocks and check if map is empty m_downloadCond.Lock(); /* // high debug print @@ -160,7 +160,6 @@ bool File::ioActive() } */ - // 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) { @@ -191,7 +190,13 @@ bool File::ioActive() //______________________________________________________________________________ - +void File::WakeUp() +{ + // called if this object is recycled by other IO + m_stateCond.Lock(); + if (m_prefetchState != kComplete) m_prefetchState = kOn; + m_stateCond.UnLock(); +} //============================================================================== diff --git a/src/XrdFileCache/XrdFileCacheFile.hh b/src/XrdFileCache/XrdFileCacheFile.hh index 9c5f5693f71..9f7c7d597bd 100644 --- a/src/XrdFileCache/XrdFileCacheFile.hh +++ b/src/XrdFileCache/XrdFileCacheFile.hh @@ -192,6 +192,8 @@ namespace XrdFileCache XrdOucTrace* GetTrace(); long long GetFileSize() { return m_fileSize;} + + void WakeUp(); private: bool overlap(int blk, // block to query long long blk_size, // diff --git a/src/XrdFileCache/XrdFileCacheIOEntireFile.cc b/src/XrdFileCache/XrdFileCacheIOEntireFile.cc index 13acc030aaf..6734b51539e 100644 --- a/src/XrdFileCache/XrdFileCacheIOEntireFile.cc +++ b/src/XrdFileCache/XrdFileCacheIOEntireFile.cc @@ -42,8 +42,12 @@ IOEntireFile::IOEntireFile(XrdOucCacheIO2 *io, XrdOucCacheStats &stats, Cache & XrdCl::URL url(m_io->Path()); std::string fname = Cache::GetInstance().RefConfiguration().m_cache_dir + url.GetPath(); - if (!(m_file = Cache::GetInstance().GetFileWithLocalPath(fname, this))) + if ((m_file = Cache::GetInstance().GetFileWithLocalPath(fname, this))) { + m_file->WakeUp(); + } + else { + struct stat st; int res = Fstat(st);