forked from premiere/premiere-libtorrent
consistency fixes related to shutting down
This commit is contained in:
parent
755d9f5967
commit
f83db0a423
|
@ -1001,13 +1001,11 @@ namespace libtorrent
|
|||
, m_download_queue.end()
|
||||
, block_finished);
|
||||
|
||||
std::deque<piece_block>::iterator i;
|
||||
|
||||
if (b != m_download_queue.end())
|
||||
{
|
||||
if (m_assume_fifo)
|
||||
{
|
||||
for (i = m_download_queue.begin();
|
||||
for (std::deque<piece_block>::iterator i = m_download_queue.begin();
|
||||
i != b; ++i)
|
||||
{
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
|
@ -1115,6 +1113,23 @@ namespace libtorrent
|
|||
{
|
||||
t->piece_failed(p.piece);
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
if (!t->is_seed())
|
||||
{
|
||||
const int blocks_per_piece = static_cast<int>(
|
||||
t->torrent_file().piece_length() / t->block_size());
|
||||
|
||||
std::vector<piece_picker::downloading_piece> const& dl_queue
|
||||
= t->picker().get_download_queue();
|
||||
|
||||
for (std::vector<piece_picker::downloading_piece>::const_iterator i =
|
||||
dl_queue.begin(); i != dl_queue.end(); ++i)
|
||||
{
|
||||
assert(int(i->finished_blocks.count()) < blocks_per_piece);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
t->get_policy().piece_finished(p.piece, verified);
|
||||
|
||||
if (!was_seed && t->is_seed())
|
||||
|
|
|
@ -971,7 +971,7 @@ namespace libtorrent
|
|||
assert(i != m_downloads.end());
|
||||
assert((int)i->finished_blocks.count() <= m_blocks_per_piece);
|
||||
int max_blocks = blocks_in_piece(index);
|
||||
if ((int)i->finished_blocks.count() != max_blocks) return false;
|
||||
if ((int)i->finished_blocks.count() < max_blocks) return false;
|
||||
|
||||
assert((int)i->requested_blocks.count() == max_blocks);
|
||||
return true;
|
||||
|
|
|
@ -1029,17 +1029,18 @@ namespace libtorrent { namespace detail
|
|||
void session_impl::connection_completed(
|
||||
boost::intrusive_ptr<peer_connection> const& p)
|
||||
#ifndef NDEBUG
|
||||
try
|
||||
try
|
||||
#endif
|
||||
{
|
||||
mutex_t::scoped_lock l(m_mutex);
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
connection_map::iterator i = m_half_open.find(p->get_socket());
|
||||
m_connections.insert(std::make_pair(p->get_socket(), p));
|
||||
assert(i != m_half_open.end());
|
||||
if (i != m_half_open.end()) m_half_open.erase(i);
|
||||
|
||||
if (m_abort) return;
|
||||
|
||||
process_connection_queue();
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
|
@ -1123,13 +1124,13 @@ namespace libtorrent { namespace detail
|
|||
assert(m_abort);
|
||||
m_abort = true;
|
||||
|
||||
while (!m_connections.empty())
|
||||
m_connections.begin()->second->disconnect();
|
||||
m_connection_queue.clear();
|
||||
|
||||
while (!m_half_open.empty())
|
||||
m_half_open.begin()->second->disconnect();
|
||||
|
||||
m_connection_queue.clear();
|
||||
while (!m_connections.empty())
|
||||
m_connections.begin()->second->disconnect();
|
||||
|
||||
#ifndef NDEBUG
|
||||
for (torrent_map::iterator i = m_torrents.begin();
|
||||
|
|
Loading…
Reference in New Issue