fixed bug leaking file lists. Do not use previous commit: it will leak your file lists.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8106 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-04-01 21:08:30 +00:00
parent a32acc67bb
commit 6594156442
4 changed files with 23 additions and 23 deletions

View File

@ -233,25 +233,25 @@ bool CacheSource::clearCache(CacheId id)
return ret;
}
bool CacheSource::cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids)
{
if(!isPeerAcceptedAsCacheReceiver(pid))
return false ;
lockData(); /* LOCK MUTEX */
/* can overwrite for more control! */
CacheSet::iterator it;
for(it = caches.begin(); it != caches.end(); ++it)
{
ids[(it->second).cid] = it->second;
}
bool ret = (caches.size() > 0);
unlockData(); /* UNLOCK MUTEX */
return ret;
}
//bool CacheSource::cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids)
//{
// if(!isPeerAcceptedAsCacheReceiver(pid))
// return false ;
//
// lockData(); /* LOCK MUTEX */
//
// /* can overwrite for more control! */
// CacheSet::iterator it;
// for(it = caches.begin(); it != caches.end(); ++it)
// {
// ids[(it->second).cid] = it->second;
// }
// bool ret = (caches.size() > 0);
//
// unlockData(); /* UNLOCK MUTEX */
// return ret;
//
//}
bool CacheSource::findCache(const RsFileHash &hash, RsCacheData &data) const

View File

@ -167,7 +167,7 @@ class CacheSource
* called to determine available cache for peer -
* default acceptable (returns all)
*/
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids);
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids)=0;
/*!
* function called at startup to load from

View File

@ -1300,7 +1300,7 @@ time_t FileIndexMonitor::locked_saveFileIndexes(bool update_cache)
return mod_time ;
}
bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, RsCacheData> &ids)
bool FileIndexMonitor::cachesAvailable(const RsPeerId &pid,std::map<CacheId, RsCacheData> &ids)
{
lockData() ;
#ifdef FIM_DEBUG
@ -1314,7 +1314,7 @@ bool FileIndexMonitor::cachesAvailable(RsPeerId pid,std::map<CacheId, RsCacheDat
RsPeerId ownId = rsPeers->getOwnId();
if(it != _cache_items_per_peer.end())
{
{
ids[it->second.cid] = it->second ;
if(pid != ownId)

View File

@ -151,7 +151,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
/* util fns */
// from CacheSource
virtual bool cachesAvailable(RsPeerId /* pid */, std::map<CacheId, RsCacheData> &ids) ;
virtual bool cachesAvailable(const RsPeerId& pid, std::map<CacheId, RsCacheData> &ids) ;
protected:
// Sets/gets the duration period within which already hashed files are remembered.