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; buffer_offset += to_copy;
if (m_settings.volatile_read_cache) if (m_settings.volatile_read_cache)
{ {
free_buffer(p.blocks[block].buf); // if volatile read cache is set, the assumption is
p.blocks[block].buf = 0; // that no other peer is likely to request the same
--p.num_blocks; // piece. Therefore, for each request out of the cache
--m_cache_stats.cache_size; // we clear the block that was requested and any blocks
--m_cache_stats.read_cache_size; // 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; ++block;
} }