Skip to content

Commit

Permalink
Check write queue size.
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and abh3 committed Jun 30, 2016
1 parent 601a1a8 commit 72883c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/XrdFileCache/XrdFileCache.cc
Expand Up @@ -99,24 +99,15 @@ void Cache::Detach(XrdOucCacheIO* io)

delete io;
}

// XXXX MT: is the following needed ???
//______________________________________________________________________________
void Cache::getFilePathFromURL(const char* iUrl, std::string &result) const
{
XrdCl::URL url(iUrl);
result = Factory::GetInstance().RefConfiguration().m_cache_dir + url.GetPath();
}

// XXXX MT: is the following needed ???
//______________________________________________________________________________
bool
Cache::HaveFreeWritingSlots()
{

XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::HaveFreeWritingSlots() %ld", s_writeQ.size);
const static size_t maxWriteWaits=500;
return s_writeQ.size < maxWriteWaits;
}

//______________________________________________________________________________
void
Cache::AddWriteTask(Block* b, bool fromRead)
Expand Down Expand Up @@ -266,7 +257,7 @@ Cache::Prefetch()
while (true) {
bool doPrefetch = false;
m_RAMblock_mutex.Lock();
if (m_RAMblocks_used < limitRAM)
if (m_RAMblocks_used < limitRAM && HaveFreeWritingSlots())
doPrefetch = true;
m_RAMblock_mutex.UnLock();

Expand All @@ -275,12 +266,13 @@ Cache::Prefetch()
XrdCl::DefaultEnv::GetLog()->Dump(XrdCl::AppMsg, "Cache::Prefetch got file (%p)", f);
if (f) {
f->Prefetch();
XrdSysTimer::Wait(1);
continue;
}
}

// wait for new file or more resources, AMT should I wait for the signal instead ???
XrdSysTimer::Wait(1);
XrdSysTimer::Wait(10);

}
}
4 changes: 4 additions & 0 deletions src/XrdFileCache/XrdFileCache.hh
Expand Up @@ -68,6 +68,10 @@ namespace XrdFileCache
//---------------------------------------------------------------------
void AddWriteTask(Block* b, bool from_read);

//---------------------------------------------------------------------
//! Check write queue size is not over limit.
//---------------------------------------------------------------------
bool HaveFreeWritingSlots();

//---------------------------------------------------------------------
//! \brief Remove blocks from write queue which belong to given prefetch.
Expand Down

0 comments on commit 72883c9

Please sign in to comment.