fix incorrect comparison function when deciding which peer to disconnect (#746)

fix incorrect comparison function when deciding which peer to disconnect
This commit is contained in:
Arvid Norberg 2016-05-22 13:46:37 -04:00
parent 3988a443ff
commit b5fc367d17
3 changed files with 21 additions and 5 deletions

View File

@ -2555,8 +2555,12 @@ retry:
{
// now, disconnect a random peer
torrent_map::iterator i = std::max_element(m_torrents.begin()
, m_torrents.end(), boost::bind(&torrent::num_peers
, boost::bind(&torrent_map::value_type::second, _1)));
, m_torrents.end()
, boost::bind(&torrent::num_peers
, boost::bind(&torrent_map::value_type::second, _1))
< boost::bind(&torrent::num_peers
, boost::bind(&torrent_map::value_type::second, _2))
);
if (m_alerts.should_post<performance_alert>())
m_alerts.emplace_alert<performance_alert>(

View File

@ -31,7 +31,13 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include "libtorrent/session.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "test.hpp"
#include "setup_transfer.hpp"
@ -101,7 +107,7 @@ TORRENT_TEST(load_empty_file)
add_torrent_params atp;
error_code ignore_errors;
atp.ti = boost::make_shared<torrent_info>("", 0, ignore_errors);
atp.ti = boost::make_shared<torrent_info>("", 0, boost::ref(ignore_errors));
atp.save_path = ".";
error_code ec;
torrent_handle h = ses.add_torrent(atp, ec);
@ -141,7 +147,7 @@ TORRENT_TEST(paused_session)
h.resume();
test_sleep(1000);
TEST_CHECK(!h.is_paused());
TEST_CHECK(!h.status().paused);
}
#if __cplusplus >= 201103L

View File

@ -36,7 +36,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/create_torrent.hpp"
#include "libtorrent/announce_entry.hpp"
#include "libtorrent/aux_/escape_string.hpp" // for convert_path_to_posix
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/make_shared.hpp>
#include <boost/ref.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#if TORRENT_USE_IOSTREAM
#include <sstream>
@ -857,7 +863,7 @@ TORRENT_TEST(resolve_duplicates)
TORRENT_TEST(empty_file)
{
error_code ec;
boost::shared_ptr<torrent_info> ti = boost::make_shared<torrent_info>("", 0, ec);
boost::shared_ptr<torrent_info> ti = boost::make_shared<torrent_info>("", 0, boost::ref(ec));
TEST_CHECK(ec);
}