fix assert when pausing session while checking torrents

This commit is contained in:
Arvid Norberg 2011-06-03 08:40:13 +00:00
parent 187361cc20
commit ebba1f3c57
2 changed files with 19 additions and 7 deletions

View File

@ -1382,7 +1382,7 @@ namespace aux {
, end(m_torrents.end()); i != end; ++i)
{
torrent& t = *i->second;
if (!t.is_torrent_paused()) t.do_pause();
t.do_pause();
}
}
@ -1398,6 +1398,7 @@ namespace aux {
torrent& t = *i->second;
t.do_resume();
}
if (!m_queued_for_checking.empty()) m_queued_for_checking.front()->start_checking();
}
void session_impl::abort()
@ -5229,7 +5230,7 @@ namespace aux {
}
// the queue is either empty, or it has exactly one checking torrent in it
TORRENT_ASSERT(m_queued_for_checking.empty() || num_checking == 1);
TORRENT_ASSERT(m_queued_for_checking.empty() || num_checking == 1 || (m_paused && num_checking == 0));
std::set<int> unique;
int total_downloaders = 0;

View File

@ -5661,11 +5661,21 @@ namespace libtorrent
++found;
if (i->second->should_check_files()) ++found_active;
}
// the case of 2 is in the special case where one switches over from
// checking to complete.
TORRENT_ASSERT(found_active >= 1);
TORRENT_ASSERT(found_active <= 2);
TORRENT_ASSERT(found >= 1);
// if the session is paused, there might still be some torrents
// in the checking_files state that haven't been dequeued yet
if (m_ses.is_paused())
{
TORRENT_ASSERT(found_active == 0);
}
else
{
// the case of 2 is in the special case where one switches over from
// checking to complete.
TORRENT_ASSERT(found_active >= 1);
TORRENT_ASSERT(found_active <= 2);
TORRENT_ASSERT(found >= 1);
}
}
TORRENT_ASSERT(m_resume_entry.type() == lazy_entry::dict_t
@ -6309,6 +6319,7 @@ namespace libtorrent
m_storage->abort_disk_io();
dequeue_torrent_check();
set_state(torrent_status::queued_for_checking);
TORRENT_ASSERT(!m_queued_for_checking);
}
// if this torrent was just paused