volatile cache improvement

This commit is contained in:
Arvid Norberg 2010-02-06 17:56:58 +00:00
parent 5d4ce032f9
commit c263f8daf7
1 changed files with 13 additions and 5 deletions

View File

@ -1229,11 +1229,19 @@ namespace libtorrent
buffer_offset += to_copy;
if (m_settings.volatile_read_cache)
{
free_buffer(p.blocks[block].buf);
p.blocks[block].buf = 0;
--p.num_blocks;
--m_cache_stats.cache_size;
--m_cache_stats.read_cache_size;
// if volatile read cache is set, the assumption is
// that no other peer is likely to request the same
// piece. Therefore, for each request out of the cache
// we clear the block that was requested and any blocks
// the peer skipped
for (int i = block; i >= 0 && p.blocks[i].buf; --i)
{
free_buffer(p.blocks[i].buf);
p.blocks[i].buf = 0;
--p.num_blocks;
--m_cache_stats.cache_size;
--m_cache_stats.read_cache_size;
}
}
++block;
}