some asserts in disk_io_thread. fix issue in torrent::initialize

This commit is contained in:
Arvid Norberg 2014-07-12 19:23:31 +00:00
parent 6e0e64e2ff
commit c8e8eb6e15
3 changed files with 9 additions and 3 deletions

View File

@ -332,6 +332,9 @@ void block_cache::cache_hit(cached_piece_entry* p, void* requester, bool volatil
// this can be pretty expensive
// INVARIANT_CHECK;
TORRENT_ASSERT(p);
TORRENT_ASSERT(p->in_use);
// move the piece into this queue. Whenever we have a cahe
// hit, we move the piece into the lru2 queue (i.e. the most
// frequently used piece). However, we only do that if the

View File

@ -2307,6 +2307,7 @@ namespace libtorrent
cached_piece_entry* pe = m_disk_cache.find_piece(j);
if (pe)
{
TORRENT_ASSERT(pe->in_use);
#if TORRENT_USE_ASSERTS
pe->piece_log.push_back(piece_log_t(j->action));
#endif

View File

@ -1741,11 +1741,13 @@ namespace libtorrent
m_connections_initialized = true;
// all peer connections have to initialize themselves now that the metadata
// is available
for (torrent::peer_iterator i = m_connections.begin();
i != m_connections.end();)
// copy the peer list since peers may disconnect and invalidate
// m_connections as we initialize them
std::vector<peer_connection*> peers = m_connections;
for (torrent::peer_iterator i = peers.begin();
i != peers.end(); ++i)
{
peer_connection* pc = *i;
++i;
if (pc->is_disconnecting()) continue;
pc->on_metadata_impl();
if (pc->is_disconnecting()) continue;