fix cache eviction issue in seed_mode

This commit is contained in:
Arvid Norberg 2011-08-07 07:27:38 +00:00
parent f6554bad08
commit ecba902ff1
1 changed files with 8 additions and 3 deletions

View File

@ -1037,15 +1037,20 @@ namespace libtorrent
TORRENT_ASSERT(j.cache_min_time >= 0);
mutex::scoped_lock l(m_piece_mutex);
int piece_size = j.storage->info()->piece_size(j.piece);
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
if (in_use() + blocks_in_piece >= m_settings.cache_size)
{
flush_cache_blocks(l, in_use() - m_settings.cache_size + blocks_in_piece);
}
cache_piece_index_t::iterator p;
bool hit;
int ret = cache_piece(j, p, hit, ignore_cache_size, l);
if (ret < 0) return ret;
int piece_size = j.storage->info()->piece_size(j.piece);
int blocks_in_piece = (piece_size + m_block_size - 1) / m_block_size;
if (!m_settings.disable_hash_checks)
{
hasher ctx;