From 820fd29bff9eb543cb4b3a4856173ee66c33088e Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 22 Dec 2016 21:43:05 -0500 Subject: [PATCH 1/7] add missing session stats functions to python bindings --- bindings/python/src/converters.cpp | 17 +++++++++++++++++ bindings/python/src/session.cpp | 19 +++++++++++++------ bindings/python/test.py | 13 +++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index d69f52c92..cb84e32bf 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -6,6 +6,7 @@ #include "libtorrent/address.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" +#include "libtorrent/session_stats.hpp" using namespace boost::python; namespace bp = boost::python; @@ -66,6 +67,20 @@ struct tuple_to_pair } }; +template +struct vector_to_list +{ + static PyObject* convert(const std::vector& v) + { + list l; + for (int i = 0; i < int(v.size()); ++i) + { + l.append(v[i]); + } + return incref(l.ptr()); + } +}; + void bind_converters() { namespace lt = libtorrent; @@ -74,4 +89,6 @@ void bind_converters() to_python_converter >(); to_python_converter(); tuple_to_pair(); + + to_python_converter, vector_to_list>(); } diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index c0d83d205..3e51ab0c7 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -17,6 +17,7 @@ #include #include // for sign_mutable_item #include +#include #ifndef TORRENT_NO_DEPRECATE #include @@ -952,12 +953,6 @@ void bind_session() .def("set_settings", &set_feed_settings) .def("settings", &get_feed_settings) ; -#endif - - typedef void (*mem_preset2)(settings_pack& s); - typedef void (*perf_preset2)(settings_pack& s); - -#ifndef TORRENT_NO_DEPRECATE typedef session_settings (*mem_preset1)(); typedef session_settings (*perf_preset1)(); @@ -967,9 +962,21 @@ void bind_session() scope().attr("create_metadata_plugin") = "metadata_transfer"; #endif + typedef void (*mem_preset2)(settings_pack& s); + typedef void (*perf_preset2)(settings_pack& s); + def("high_performance_seed", (perf_preset2)high_performance_seed); def("min_memory_usage", (mem_preset2)min_memory_usage); + class_("stats_metric") + .def_readonly("name", &stats_metric::name) + .def_readonly("value_index", &stats_metric::value_index) + .def_readonly("type", &stats_metric::type) + ; + + def("session_stats_metrics", session_stats_metrics); + def("find_metric_idx", find_metric_idx); + scope().attr("create_ut_metadata_plugin") = "ut_metadata"; scope().attr("create_ut_pex_plugin") = "ut_pex"; scope().attr("create_smart_ban_plugin") = "smart_ban"; diff --git a/bindings/python/test.py b/bindings/python/test.py index e594f11dc..322681327 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -22,6 +22,19 @@ class test_create_torrent(unittest.TestCase): print(entry) self.assertEqual(content, file_content) +class test_session_stats(unittest.TestCase): + + def test_unique(self): + l = lt.session_stats_metrics() + self.assertTrue(len(l) > 40); + idx = set() + for m in l: + self.assertTrue(m.value_index not in idx) + idx.add(m.value_index) + + def test_find_idx(self): + self.assertEqual(lt.find_metric_idx("peer.error_peers"), 0) + class test_torrent_handle(unittest.TestCase): def test_torrent_handle(self): From a6de426d1e7af66d4d726388f19d054d31e910cf Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 23 Dec 2016 13:57:10 -0800 Subject: [PATCH 2/7] add file_status to python binding (#1448) add more missing functions to python bindings --- bindings/python/src/converters.cpp | 6 ++- bindings/python/src/torrent_handle.cpp | 21 ++++++++ bindings/python/src/torrent_info.cpp | 24 ++++++++- bindings/python/src/torrent_status.cpp | 8 +++ bindings/python/test.py | 70 ++++++++++++++++++-------- 5 files changed, 106 insertions(+), 23 deletions(-) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index cb84e32bf..fe2785e76 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -6,7 +6,8 @@ #include "libtorrent/address.hpp" #include "libtorrent/socket.hpp" #include "libtorrent/error_code.hpp" -#include "libtorrent/session_stats.hpp" +#include "libtorrent/session_stats.hpp" // for stats_metric +#include "libtorrent/file_pool.hpp" // for file_pool_status using namespace boost::python; namespace bp = boost::python; @@ -91,4 +92,7 @@ void bind_converters() tuple_to_pair(); to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list>(); } diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index bdb93d75a..5a8ff4c44 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -12,6 +12,7 @@ #include #include "libtorrent/announce_entry.hpp" #include +#include #include #include "gil.hpp" @@ -314,6 +315,13 @@ void connect_peer(torrent_handle& th, tuple ip, int source) th.connect_peer(tuple_to_endpoint(ip), source); } +std::vector file_status(torrent_handle const& h) +{ + std::vector ret; + h.file_status(ret); + return ret; +} + #ifndef TORRENT_NO_DEPRECATE #if BOOST_VERSION > 104200 @@ -444,6 +452,7 @@ void bind_torrent_handle() .def("set_piece_deadline", _(&torrent_handle::set_piece_deadline) , (arg("index"), arg("deadline"), arg("flags") = 0)) .def("reset_piece_deadline", _(&torrent_handle::reset_piece_deadline), (arg("index"))) + .def("clear_piece_deadlines", _(&torrent_handle::clear_piece_deadlines), (arg("index"))) .def("piece_availability", &piece_availability) .def("piece_priority", _(piece_priority0)) .def("piece_priority", _(piece_priority1)) @@ -453,6 +462,7 @@ void bind_torrent_handle() .def("file_priorities", &file_priorities) .def("file_priority", &file_prioritity0) .def("file_priority", &file_prioritity1) + .def("file_status", &::file_status) .def("save_resume_data", _(&torrent_handle::save_resume_data), arg("flags") = 0) .def("need_save_resume_data", _(&torrent_handle::need_save_resume_data)) .def("force_reannounce", _(force_reannounce0) @@ -495,16 +505,27 @@ void bind_torrent_handle() #endif ; + class_("pool_file_status") + .def_readonly("file_index", &pool_file_status::file_index) + .def_readonly("last_use", &pool_file_status::last_use) + .def_readonly("open_mode", &pool_file_status::open_mode) + ; + enum_("file_progress_flags") .value("piece_granularity", torrent_handle::piece_granularity) ; + enum_("add_piece_flags_t") + .value("overwrite_existing", torrent_handle::overwrite_existing) + ; enum_("pause_flags_t") .value("graceful_pause", torrent_handle::graceful_pause) ; enum_("save_resume_flags_t") .value("flush_disk_cache", torrent_handle::flush_disk_cache) + .value("save_info_dict", torrent_handle::save_info_dict) + .value("only_if_modified", torrent_handle::only_if_modified) ; enum_("deadline_flags") diff --git a/bindings/python/src/torrent_info.cpp b/bindings/python/src/torrent_info.cpp index 477c6fcdc..97afbb447 100644 --- a/bindings/python/src/torrent_info.cpp +++ b/bindings/python/src/torrent_info.cpp @@ -62,13 +62,28 @@ namespace d["url"] = i->url; d["type"] = i->type; d["auth"] = i->auth; - d["extra_headers"] = i->extra_headers; ret.append(d); } return ret; } + void set_web_seeds(torrent_info& ti, list ws) + { + std::vector web_seeds; + int const len = boost::python::len(ws); + for (int i = 0; i < len; i++) + { + dict e = extract(ws[i]); + int const type = extract(e["type"]); + web_seeds.push_back(web_seed_entry( + extract(e["url"]) + , static_cast(type) + , extract(e["auth"]))); + } + ti.set_web_seeds(web_seeds); + } + list get_merkle_tree(torrent_info const& ti) { std::vector const& mt = ti.merkle_tree(); @@ -228,6 +243,7 @@ void bind_torrent_info() .def("add_url_seed", &torrent_info::add_url_seed) .def("add_http_seed", &torrent_info::add_http_seed) .def("web_seeds", get_web_seeds) + .def("set_web_seeds", set_web_seeds) .def("name", &torrent_info::name, copy) .def("comment", &torrent_info::comment, copy) @@ -241,6 +257,9 @@ void bind_torrent_info() .def("set_merkle_tree", set_merkle_tree) .def("piece_size", &torrent_info::piece_size) + .def("similar_torrents", &torrent_info::similar_torrents) + .def("collections", &torrent_info::collections) + .def("ssl_cert", &torrent_info::ssl_cert) .def("num_files", &torrent_info::num_files) .def("rename_file", rename_file0) .def("remap_files", &torrent_info::remap_files) @@ -254,7 +273,10 @@ void bind_torrent_info() #endif // TORRENT_USE_WSTRING #endif // TORRENT_NO_DEPRECATE + .def("is_valid", &torrent_info::is_valid) .def("priv", &torrent_info::priv) + .def("is_i2p", &torrent_info::is_i2p) + .def("is_merkle_torrent", &torrent_info::is_merkle_torrent) .def("trackers", range(begin_trackers, end_trackers)) .def("creation_date", &torrent_info::creation_date) diff --git a/bindings/python/src/torrent_status.cpp b/bindings/python/src/torrent_status.cpp index fc74eddfa..4b8737eec 100644 --- a/bindings/python/src/torrent_status.cpp +++ b/bindings/python/src/torrent_status.cpp @@ -22,10 +22,18 @@ object bitfield_to_list(bitfield const& bf) object pieces(torrent_status const& s) { return bitfield_to_list(s.pieces); } object verified_pieces(torrent_status const& s) { return bitfield_to_list(s.verified_pieces); } +boost::shared_ptr get_torrent_file(torrent_status const& st) +{ + return st.torrent_file.lock(); +} + void bind_torrent_status() { scope status = class_("torrent_status") + .def(self == self) + .def_readonly("handle", &torrent_status::handle) .def_readonly("info_hash", &torrent_status::info_hash) + .add_property("torrent_file", &get_torrent_file) .def_readonly("state", &torrent_status::state) .def_readonly("paused", &torrent_status::paused) .def_readonly("stop_when_ready", &torrent_status::stop_when_ready) diff --git a/bindings/python/test.py b/bindings/python/test.py index 322681327..8aa6390c2 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -37,38 +37,53 @@ class test_session_stats(unittest.TestCase): class test_torrent_handle(unittest.TestCase): + def setup(self): + self.ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False}) + self.ti = lt.torrent_info('url_seed_multi.torrent'); + self.h = self.ses.add_torrent({'ti': self.ti, 'save_path': os.getcwd()}) + def test_torrent_handle(self): - ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False}) - ti = lt.torrent_info('url_seed_multi.torrent'); - h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()}) + self.setup() + self.assertEqual(self.h.file_priorities(), [4,4]) + self.assertEqual(self.h.piece_priorities(), [4]) - self.assertEqual(h.file_priorities(), [4,4]) - self.assertEqual(h.piece_priorities(), [4]) + self.h.prioritize_files([0,1]) + self.assertEqual(self.h.file_priorities(), [0,1]) - h.prioritize_files([0,1]) - self.assertEqual(h.file_priorities(), [0,1]) + self.h.prioritize_pieces([0]) + self.assertEqual(self.h.piece_priorities(), [0]) - h.prioritize_pieces([0]) - self.assertEqual(h.piece_priorities(), [0]) + # also test the overload that takes a list of piece->priority mappings + self.h.prioritize_pieces([(0, 1)]) + self.assertEqual(self.h.piece_priorities(), [1]) - # also test the overload that takes a list of piece->priority mappings - h.prioritize_pieces([(0, 1)]) - self.assertEqual(h.piece_priorities(), [1]) + def test_file_status(self): + self.setup() + l = self.h.file_status() + print(l) + + def test_piece_deadlines(self): + self.setup() + self.h.clear_piece_deadlines() + + def test_torrent_status(self): + self.setup() + st = self.h.status() + ti = st.handle; + self.assertEqual(ti.info_hash(), self.ti.info_hash()) + # make sure we can compare torrent_status objects + st2 = self.h.status() + self.assertEqual(st2, st) def test_scrape(self): - ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False}) - ti = lt.torrent_info('url_seed_multi.torrent'); - h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()}) + self.setup() # this is just to make sure this function can be called like this # from python - h.scrape_tracker() + self.h.scrape_tracker() def test_cache_info(self): - ses = lt.session({'alert_mask': lt.alert.category_t.all_categories, 'enable_dht': False}) - ti = lt.torrent_info('url_seed_multi.torrent'); - h = ses.add_torrent({'ti': ti, 'save_path': os.getcwd()}) - - cs = ses.get_cache_info(h) + self.setup() + cs = self.ses.get_cache_info(self.h) self.assertEqual(cs.pieces, []) class test_torrent_info(unittest.TestCase): @@ -91,6 +106,19 @@ class test_torrent_info(unittest.TestCase): self.assertTrue(len(ti.metadata()) != 0) self.assertTrue(len(ti.hash_for_piece(0)) != 0) + def test_web_seeds(self): + ti = lt.torrent_info('base.torrent'); + + ws = [{'url': 'http://foo/test', 'auth': '', 'type': 0}, + {'url': 'http://bar/test', 'auth': '', 'type': 1} ] + ti.set_web_seeds(ws) + web_seeds = ti.web_seeds() + self.assertEqual(len(ws), len(web_seeds)) + for i in range(len(web_seeds)): + self.assertEqual(web_seeds[i]["url"], ws[i]["url"]) + self.assertEqual(web_seeds[i]["auth"], ws[i]["auth"]) + self.assertEqual(web_seeds[i]["type"], ws[i]["type"]) + def test_iterable_files(self): # this detects whether libtorrent was built with deprecated APIs From fa7846d1fdfae8715459b4f2ba04d7af52b6d3d3 Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 23 Dec 2016 18:26:06 -0800 Subject: [PATCH 3/7] fix c++98 build --- bindings/python/src/converters.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index fe2785e76..a6519da5f 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -91,8 +91,8 @@ void bind_converters() to_python_converter(); tuple_to_pair(); - to_python_converter, vector_to_list>(); - to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list >(); + to_python_converter, vector_to_list >(); to_python_converter, vector_to_list>(); - to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list >(); } From eb5b0e9897b9ff4d08506e257e3201bb56fa923d Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 24 Dec 2016 11:27:58 -0800 Subject: [PATCH 4/7] fix another c++98 issue --- bindings/python/src/converters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/python/src/converters.cpp b/bindings/python/src/converters.cpp index a6519da5f..9d74de9b5 100644 --- a/bindings/python/src/converters.cpp +++ b/bindings/python/src/converters.cpp @@ -93,6 +93,6 @@ void bind_converters() to_python_converter, vector_to_list >(); to_python_converter, vector_to_list >(); - to_python_converter, vector_to_list>(); + to_python_converter, vector_to_list >(); to_python_converter, vector_to_list >(); } From 6520fcebf1542211971359e2f93e51d1efb91687 Mon Sep 17 00:00:00 2001 From: Falcosc Date: Mon, 26 Dec 2016 17:09:52 +0100 Subject: [PATCH 5/7] fix session invariant check fail for difficult setting dependencies (#1449) clean up session_impl invariant checks --- src/session_impl.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 0fdbbc047..b9a1c1a70 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -558,6 +558,7 @@ namespace aux { void session_impl::init(boost::shared_ptr pack) { + INVARIANT_CHECK; // this is a debug facility // see single_threaded in debug.hpp thread_started(); @@ -1649,6 +1650,7 @@ namespace aux { // session_impl is responsible for deleting 'pack' void session_impl::apply_settings_pack(boost::shared_ptr pack) { + INVARIANT_CHECK; apply_settings_pack_impl(*pack); } @@ -1685,6 +1687,7 @@ namespace aux { != m_settings.get_str(settings_pack::listen_interfaces)); apply_pack(&pack, m_settings, this); + m_disk_thread.set_settings(&pack, m_alerts); if (reopen_listen_port) @@ -1700,7 +1703,7 @@ namespace aux { INVARIANT_CHECK; TORRENT_ASSERT(is_single_thread()); boost::shared_ptr p = load_pack_from_struct(m_settings, s); - apply_settings_pack(p); + apply_settings_pack_impl(*p); } libtorrent::session_settings session_impl::deprecated_settings() const @@ -3271,7 +3274,6 @@ retry: if (!m_paused) m_auto_manage_time_scaler--; if (m_auto_manage_time_scaler < 0) { - INVARIANT_CHECK; m_auto_manage_time_scaler = settings().get_int(settings_pack::auto_manage_interval); recalculate_auto_managed_torrents(); } @@ -5119,7 +5121,6 @@ retry: void session_impl::update_outgoing_interfaces() { - INVARIANT_CHECK; std::string net_interfaces = m_settings.get_str(settings_pack::outgoing_interfaces); // declared in string_util.hpp @@ -5314,7 +5315,6 @@ retry: void session_impl::update_listen_interfaces() { - INVARIANT_CHECK; std::string net_interfaces = m_settings.get_str(settings_pack::listen_interfaces); std::vector > new_listen_interfaces; @@ -6191,6 +6191,7 @@ retry: void session_impl::set_local_download_rate_limit(int bytes_per_second) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::local_download_rate_limit, bytes_per_second); apply_settings_pack_impl(p); @@ -6198,6 +6199,7 @@ retry: void session_impl::set_local_upload_rate_limit(int bytes_per_second) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::local_upload_rate_limit, bytes_per_second); apply_settings_pack_impl(p); @@ -6205,6 +6207,7 @@ retry: void session_impl::set_download_rate_limit(int bytes_per_second) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::download_rate_limit, bytes_per_second); apply_settings_pack_impl(p); @@ -6212,6 +6215,7 @@ retry: void session_impl::set_upload_rate_limit(int bytes_per_second) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::upload_rate_limit, bytes_per_second); apply_settings_pack_impl(p); @@ -6219,6 +6223,7 @@ retry: void session_impl::set_max_connections(int limit) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::connections_limit, limit); apply_settings_pack_impl(p); @@ -6226,6 +6231,7 @@ retry: void session_impl::set_max_uploads(int limit) { + INVARIANT_CHECK; settings_pack p; p.set_int(settings_pack::unchoke_slots_limit, limit); apply_settings_pack_impl(p); From 2f75dcccfe5f6ccb1106667ac4fa0db53bd3a45b Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 26 Dec 2016 08:13:55 -0800 Subject: [PATCH 6/7] on backwards compatible set_settings(), stack allocate settings_pack --- include/libtorrent/settings_pack.hpp | 2 +- src/session_impl.cpp | 4 ++-- src/settings_pack.cpp | 18 +++++++++--------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index 5c22ef1e7..c7e367c67 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -68,7 +68,7 @@ namespace libtorrent #ifndef TORRENT_NO_DEPRECATE struct session_settings; - boost::shared_ptr load_pack_from_struct(aux::session_settings const& current, session_settings const& s); + settings_pack load_pack_from_struct(aux::session_settings const& current, session_settings const& s); void load_struct_from_settings(aux::session_settings const& current, session_settings& ret); #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b9a1c1a70..7e7d60e5b 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1702,8 +1702,8 @@ namespace aux { { INVARIANT_CHECK; TORRENT_ASSERT(is_single_thread()); - boost::shared_ptr p = load_pack_from_struct(m_settings, s); - apply_settings_pack_impl(*p); + settings_pack p = load_pack_from_struct(m_settings, s); + apply_settings_pack_impl(p); } libtorrent::session_settings session_impl::deprecated_settings() const diff --git a/src/settings_pack.cpp b/src/settings_pack.cpp index 152f4b0d9..651d9170d 100644 --- a/src/settings_pack.cpp +++ b/src/settings_pack.cpp @@ -463,10 +463,10 @@ namespace libtorrent #include "libtorrent/aux_/disable_warnings_push.hpp" - boost::shared_ptr load_pack_from_struct( + settings_pack load_pack_from_struct( aux::session_settings const& current, session_settings const& s) { - boost::shared_ptr p = boost::make_shared(); + settings_pack p; for (int i = 0; i < settings_pack::num_string_settings; ++i) { @@ -474,7 +474,7 @@ namespace libtorrent std::string& val = *(std::string*)(((char*)&s) + str_settings[i].offset); int setting_name = settings_pack::string_type_base + i; if (val == current.get_str(setting_name)) continue; - p->set_str(setting_name, val); + p.set_str(setting_name, val); } for (int i = 0; i < settings_pack::num_int_settings; ++i) @@ -483,7 +483,7 @@ namespace libtorrent int& val = *(int*)(((char*)&s) + int_settings[i].offset); int setting_name = settings_pack::int_type_base + i; if (val == current.get_int(setting_name)) continue; - p->set_int(setting_name, val); + p.set_int(setting_name, val); } for (int i = 0; i < settings_pack::num_bool_settings; ++i) @@ -492,25 +492,25 @@ namespace libtorrent bool& val = *(bool*)(((char*)&s) + bool_settings[i].offset); int setting_name = settings_pack::bool_type_base + i; if (val == current.get_bool(setting_name)) continue; - p->set_bool(setting_name, val); + p.set_bool(setting_name, val); } // special case for deprecated float values int val = current.get_int(settings_pack::share_ratio_limit); if (fabs(s.share_ratio_limit - float(val) / 100.f) > 0.001f) - p->set_int(settings_pack::share_ratio_limit, s.share_ratio_limit * 100); + p.set_int(settings_pack::share_ratio_limit, s.share_ratio_limit * 100); val = current.get_int(settings_pack::seed_time_ratio_limit); if (fabs(s.seed_time_ratio_limit - float(val) / 100.f) > 0.001f) - p->set_int(settings_pack::seed_time_ratio_limit, s.seed_time_ratio_limit * 100); + p.set_int(settings_pack::seed_time_ratio_limit, s.seed_time_ratio_limit * 100); val = current.get_int(settings_pack::peer_turnover); if (fabs(s.peer_turnover - float(val) / 100.f) > 0.001) - p->set_int(settings_pack::peer_turnover, s.peer_turnover * 100); + p.set_int(settings_pack::peer_turnover, s.peer_turnover * 100); val = current.get_int(settings_pack::peer_turnover_cutoff); if (fabs(s.peer_turnover_cutoff - float(val) / 100.f) > 0.001) - p->set_int(settings_pack::peer_turnover_cutoff, s.peer_turnover_cutoff * 100); + p.set_int(settings_pack::peer_turnover_cutoff, s.peer_turnover_cutoff * 100); return p; } From 45f3f80d866a678d9c5c32fc7545eb4ede9a30c5 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 26 Dec 2016 08:23:57 -0800 Subject: [PATCH 7/7] fix windows build --- include/libtorrent/buffer.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libtorrent/buffer.hpp b/include/libtorrent/buffer.hpp index e5393b380..7013a5754 100644 --- a/include/libtorrent/buffer.hpp +++ b/include/libtorrent/buffer.hpp @@ -66,7 +66,7 @@ public: int left() const { TORRENT_ASSERT(end >= begin); - TORRENT_ASSERT(end - begin < INT_MAX); + TORRENT_ASSERT(end - begin < (std::numeric_limits::max)()); return int(end - begin); } @@ -101,7 +101,7 @@ public: int left() const { TORRENT_ASSERT(end >= begin); - TORRENT_ASSERT(end - begin < INT_MAX); + TORRENT_ASSERT(end - begin < (std::numeric_limits::max)()); return int(end - begin); } @@ -203,7 +203,7 @@ public: } std::memmove(b, e, m_begin + m_size - e); TORRENT_ASSERT(e >= b); - TORRENT_ASSERT(e - b <= std::numeric_limits::max()); + TORRENT_ASSERT(e - b <= (std::numeric_limits::max)()); TORRENT_ASSERT(boost::uint32_t(e - b) <= m_size); m_size -= e - b; }