don't delete pieces from cache with refcount > 0

This commit is contained in:
arvidn 2017-10-09 03:31:59 +02:00 committed by Arvid Norberg
parent 830ef0bedd
commit a9524550d7
1 changed files with 14 additions and 1 deletions

View File

@ -1215,7 +1215,20 @@ void block_cache::clear(tailqueue<disk_io_job>& jobs)
for (int i = 0; i < cached_piece_entry::num_lrus; ++i)
m_lru[i].get_all();
m_pieces.clear();
// it's not ok to erase pieces with a refcount > 0
// since we're cancelling all jobs though, it shouldn't be too bad
// to let the jobs already running complete.
for (cache_t::iterator i = m_pieces.begin(); i != m_pieces.end();)
{
if (i->refcount == 0 && i->piece_refcount == 0)
{
i = m_pieces.erase(i);
}
else
{
++i;
}
}
}
void block_cache::move_to_ghost(cached_piece_entry* pe)