From cd4b38cfc392cc04dbc910750c42ca9cda5f71b6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 2 Jan 2013 08:09:21 +0000 Subject: [PATCH] fix bug in disconnect candidate torrent function --- include/libtorrent/aux_/session_impl.hpp | 6 +++--- src/session_impl.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index ed2693fb4..85356039e 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -281,9 +281,9 @@ namespace libtorrent void remove_feed(feed_handle h); void get_feeds(std::vector* f) const; - boost::weak_ptr find_torrent(sha1_hash const& info_hash); - boost::weak_ptr find_torrent(std::string const& uuid); - boost::weak_ptr find_disconnect_candidate_torrent(); + boost::weak_ptr find_torrent(sha1_hash const& info_hash) const; + boost::weak_ptr find_torrent(std::string const& uuid) const; + boost::weak_ptr find_disconnect_candidate_torrent() const; peer_id const& get_peer_id() const { return m_peer_id; } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 7814a6dcd..2fd1775c9 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4803,13 +4803,13 @@ retry: // the return value from this function is valid only as long as the // session is locked! - boost::weak_ptr session_impl::find_torrent(sha1_hash const& info_hash) + boost::weak_ptr session_impl::find_torrent(sha1_hash const& info_hash) const { TORRENT_ASSERT(is_network_thread()); - torrent_map::iterator i = m_torrents.find(info_hash); + torrent_map::const_iterator i = m_torrents.find(info_hash); #ifdef TORRENT_DEBUG - for (torrent_map::iterator j + for (torrent_map::const_iterator j = m_torrents.begin(); j != m_torrents.end(); ++j) { torrent* p = boost::get_pointer(j->second); @@ -4820,11 +4820,11 @@ retry: return boost::weak_ptr(); } - boost::weak_ptr session_impl::find_torrent(std::string const& uuid) + boost::weak_ptr session_impl::find_torrent(std::string const& uuid) const { TORRENT_ASSERT(is_network_thread()); - std::map >::iterator i + std::map >::const_iterator i = m_uuids.find(uuid); if (i != m_uuids.end()) return i->second; return boost::weak_ptr(); @@ -4836,7 +4836,7 @@ retry: { // a torrent with 0 peers is never a good disconnect candidate // since there's nothing to disconnect - if ((lhs.second->num_peers() == 0) != (lhs.second->num_peers() == 0)) + if ((lhs.second->num_peers() == 0) != (rhs.second->num_peers() == 0)) return lhs.second->num_peers() != 0; // other than that, always prefer to disconnect peers from seeding torrents @@ -4847,9 +4847,9 @@ retry: return lhs.second->num_peers() > rhs.second->num_peers(); } - boost::weak_ptr session_impl::find_disconnect_candidate_torrent() + boost::weak_ptr session_impl::find_disconnect_candidate_torrent() const { - aux::session_impl::torrent_map::iterator i = std::min_element(m_torrents.begin(), m_torrents.end() + aux::session_impl::torrent_map::const_iterator i = std::min_element(m_torrents.begin(), m_torrents.end() , boost::bind(&compare_disconnect_torrent, _1, _2)); TORRENT_ASSERT(i != m_torrents.end());