add assert to storage

This commit is contained in:
Arvid Norberg 2018-09-03 09:54:03 +02:00 committed by Arvid Norberg
parent 2647ca2412
commit 51003d11ca
3 changed files with 25 additions and 1 deletions

View File

@ -1102,6 +1102,18 @@ namespace libtorrent
boost::shared_ptr<piece_manager> storage = j->storage;
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
if (storage)
{
mutex::scoped_lock l(m_cache_mutex);
boost::unordered_set<cached_piece_entry*> const& pieces = storage->cached_pieces();
for (boost::unordered_set<cached_piece_entry*>::const_iterator i = pieces.begin()
, end(pieces.end()); i != end; ++i)
{
TORRENT_ASSERT((*i)->storage == storage);
}
}
#endif
// TODO: instead of doing this. pass in the settings to each storage_interface
// call. Each disk thread could hold its most recent understanding of the settings
// in a shared_ptr, and update it every time it wakes up from a job. That way
@ -1796,6 +1808,17 @@ namespace libtorrent
j->storage = storage->shared_from_this();
j->callback = handler;
#ifdef TORRENT_EXPENSIVE_INVARIANT_CHECKS
{
mutex::scoped_lock l(m_cache_mutex);
boost::unordered_set<cached_piece_entry*> const& pieces = storage->cached_pieces();
for (boost::unordered_set<cached_piece_entry*>::const_iterator i = pieces.begin()
, end(pieces.end()); i != end; ++i)
{
TORRENT_ASSERT((*i)->storage.get() == storage);
}
}
#endif
add_fence_job(storage, j);
}

View File

@ -1765,6 +1765,7 @@ namespace libtorrent
void storage_piece_set::remove_piece(cached_piece_entry* p)
{
TORRENT_ASSERT(p->storage.get() == this);
TORRENT_ASSERT(p->in_storage == true);
TORRENT_ASSERT(m_cached_pieces.count(p) == 1);
m_cached_pieces.erase(p);

View File

@ -129,7 +129,7 @@ void test_remove_torrent(int const remove_options
|| st2.state == torrent_status::checking_resume_data);
// if nothing is being transferred after 3 seconds, we're failing the test
if (st1.upload_payload_rate == 0 && i > 30)
if (st1.total_payload_upload == 0 && i > 30)
{
TEST_ERROR("no transfer");
return;