diff --git a/libtorrent/include/libtorrent/aux_/session_impl.hpp b/libtorrent/include/libtorrent/aux_/session_impl.hpp index 79abf3cc7..22ed68d49 100644 --- a/libtorrent/include/libtorrent/aux_/session_impl.hpp +++ b/libtorrent/include/libtorrent/aux_/session_impl.hpp @@ -378,7 +378,8 @@ namespace libtorrent tracker_manager m_tracker_manager; torrent_map m_torrents; - std::list > m_queued_for_checking; + typedef std::list > check_queue_t; + check_queue_t m_queued_for_checking; // this maps sockets to their peer_connection // object. It is the complete list of all connected diff --git a/libtorrent/src/piece_picker.cpp b/libtorrent/src/piece_picker.cpp index 7de18a326..5350f00f5 100755 --- a/libtorrent/src/piece_picker.cpp +++ b/libtorrent/src/piece_picker.cpp @@ -1005,7 +1005,7 @@ namespace libtorrent p.set_not_have(); if (m_dirty) return; - if (!p.filtered()) add(index); + if (p.priority(this) >= 0) add(index); } // this is used to indicate that we succesfully have diff --git a/libtorrent/src/session_impl.cpp b/libtorrent/src/session_impl.cpp index 6b812cfbe..dd422b3a4 100755 --- a/libtorrent/src/session_impl.cpp +++ b/libtorrent/src/session_impl.cpp @@ -1771,10 +1771,17 @@ namespace aux { void session_impl::done_checking(boost::shared_ptr const& t) { - TORRENT_ASSERT(m_queued_for_checking.front() == t); - m_queued_for_checking.pop_front(); - if (!m_queued_for_checking.empty()) - m_queued_for_checking.front()->start_checking(); + check_queue_t::iterator next_check = m_queued_for_checking.begin(); + check_queue_t::iterator done = m_queued_for_checking.end(); + for (check_queue_t::iterator i = m_queued_for_checking.begin() + , end(m_queued_for_checking.end()); i != end; ++i) + { + if (*i == t) done = i; + if (next_check == done || (*next_check)->queue_position() > (*i)->queue_position()) + next_check = i; + } + if (next_check != done) (*next_check)->start_checking(); + m_queued_for_checking.erase(done); } void session_impl::remove_torrent(const torrent_handle& h, int options)