From 3763a47846b927521b0eeca68b65940c9c68974e Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 21 Jan 2017 12:08:53 -0500 Subject: [PATCH 1/9] fix truncation of peer_class field in torrent --- include/libtorrent/torrent.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 0e168ddc6..045ffc1ee 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -588,7 +588,7 @@ namespace libtorrent void set_download_limit(int limit); int download_limit() const; - peer_class_t peer_class() const { return peer_class_t(m_peer_class); } + peer_class_t peer_class() const { return m_peer_class; } void set_max_uploads(int limit, bool state_update = true); int max_uploads() const { return m_max_uploads; } @@ -1421,7 +1421,7 @@ namespace libtorrent // for torrents who have a bandwidth limit, this is != 0 // and refers to a peer_class in the session. - boost::uint16_t m_peer_class; + peer_class_t m_peer_class; // of all peers in m_connections, this is the number // of peers that are outgoing and still waiting to From 61c057947c3d9c9285cf4f3bc73644a04d6ab82e Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 17 Jan 2017 19:42:49 -0500 Subject: [PATCH 2/9] add typedefs for shared_ptr and make_shared, to make transition to 1.2 easier --- include/libtorrent/aux_/session_impl.hpp | 2 +- include/libtorrent/torrent_handle.hpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 6a6424dae..1e43d38d2 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -884,7 +884,7 @@ namespace libtorrent #endif #ifdef TORRENT_USE_OPENSSL - ssl::context* ssl_ctx() { return &m_ssl_ctx; } + ssl::context* ssl_ctx() TORRENT_OVERRIDE { return &m_ssl_ctx; } void on_incoming_utp_ssl(boost::shared_ptr const& s); void ssl_handshake(error_code const& ec, boost::shared_ptr s); #endif diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 8a0ecd2c1..8d98e6d9c 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include #include #include @@ -82,6 +83,9 @@ namespace libtorrent void throw_invalid_handle() TORRENT_NO_RETURN; #endif + using boost::shared_ptr; + using boost::make_shared; + // holds the state of a block in a piece. Who we requested // it from and how far along we are at downloading it. struct TORRENT_EXPORT block_info @@ -896,7 +900,7 @@ namespace libtorrent // without metadata only if it was started without a .torrent file, e.g. // by using the libtorrent extension of just supplying a tracker and // info-hash. - boost::shared_ptr torrent_file() const; + shared_ptr torrent_file() const; #ifndef TORRENT_NO_DEPRECATE From 132be5101ff48ecc2831e4171c4f2043b290c6f9 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 22 Jan 2017 20:36:40 +0200 Subject: [PATCH 3/9] fix stat cache issue that sometimes would produce incorrect resume data --- ChangeLog | 1 + src/storage.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index dea188316..a0ee4bf20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * fix stat cache issue that sometimes would produce incorrect resume data * storage optimization to peer classes * fix torrent name in alerts of builds with deprecated functions * make torrent_info::is_valid() return false if torrent failed to load diff --git a/src/storage.cpp b/src/storage.cpp index 43cddf09e..89235be22 100644 --- a/src/storage.cpp +++ b/src/storage.cpp @@ -545,14 +545,17 @@ namespace libtorrent file_status s; std::string file_path = files().file_path(file_index, m_save_path); stat_file(file_path, &s, ec.ec); - if (ec && ec.ec != boost::system::errc::no_such_file_or_directory) + if (!ec) + { + m_stat_cache.set_cache(file_index, s.file_size, s.mtime); + } + else if (ec.ec != boost::system::errc::no_such_file_or_directory) { m_stat_cache.set_error(file_index); ec.file = file_index; ec.operation = storage_error::stat; break; } - m_stat_cache.set_cache(file_index, s.file_size, s.mtime); } // if the file already exists, but is larger than what From 7c9679bf6aa05841716604bff4fe85805f450ce7 Mon Sep 17 00:00:00 2001 From: Andrei Kurushin Date: Mon, 23 Jan 2017 10:01:47 +0300 Subject: [PATCH 4/9] fix missed static array specifier --- include/libtorrent/error_code.hpp | 2 +- src/alert.cpp | 2 +- src/bt_peer_connection.cpp | 12 ++++++------ src/http_tracker_connection.cpp | 2 +- src/upnp.cpp | 2 +- src/ut_metadata.cpp | 2 +- src/ut_pex.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/libtorrent/error_code.hpp b/include/libtorrent/error_code.hpp index f166e203c..8cffcc11f 100644 --- a/include/libtorrent/error_code.hpp +++ b/include/libtorrent/error_code.hpp @@ -560,7 +560,7 @@ namespace libtorrent // an empty string. char const* operation_str() const { - char const* ops[] = + static char const* ops[] = { "", "stat", "mkdir", "open", "rename", "remove", "copy" , "read", "write", "fallocate", "allocate cache piece" diff --git a/src/alert.cpp b/src/alert.cpp index 8e8d2007b..5d9129da4 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -1110,7 +1110,7 @@ namespace libtorrent { std::string anonymous_mode_alert::message() const { char msg[200]; - char const* msgs[] = { + static char const* msgs[] = { "tracker is not anonymous, set a proxy" }; snprintf(msg, sizeof(msg), "%s: %s: %s" diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index e04e61801..44963475f 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -201,7 +201,7 @@ namespace libtorrent out_policy = settings_pack::pe_disabled; #endif #ifndef TORRENT_DISABLE_LOGGING - char const* policy_name[] = {"forced", "enabled", "disabled"}; + static char const* policy_name[] = {"forced", "enabled", "disabled"}; TORRENT_ASSERT(out_policy < sizeof(policy_name)/sizeof(policy_name[0])); peer_log(peer_log_alert::info, "ENCRYPTION" , "outgoing encryption policy: %s", policy_name[out_policy]); @@ -561,7 +561,7 @@ namespace libtorrent crypto_provide = settings_pack::pe_both; #ifndef TORRENT_DISABLE_LOGGING - char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; + static char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; peer_log(peer_log_alert::info, "ENCRYPTION" , "%s", level[crypto_provide-1]); #endif @@ -785,7 +785,7 @@ namespace libtorrent TORRENT_ASSERT(t); // add handshake to the send buffer - const char version_string[] = "BitTorrent protocol"; + static const char version_string[] = "BitTorrent protocol"; const int string_len = sizeof(version_string)-1; char handshake[1 + string_len + 8 + 20 + 20]; @@ -1621,7 +1621,7 @@ namespace libtorrent boost::uint32_t error = detail::read_uint32(ptr); #ifndef TORRENT_DISABLE_LOGGING error_code ec; - char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"}; + static char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"}; peer_log(peer_log_alert::incoming_message, "HOLEPUNCH" , "msg:failed error: %d msg: %s", error , ((error > 0 && error < 5)?err_msg[error-1]:"unknown message id")); @@ -2833,7 +2833,7 @@ namespace libtorrent rc4_decrypt(wr_recv_buf.begin + 20, 8); wr_recv_buf.begin += 28; - const char sh_vc[] = {0,0,0,0, 0,0,0,0}; + static const char sh_vc[] = {0,0,0,0, 0,0,0,0}; if (!std::equal(sh_vc, sh_vc+8, recv_buffer.begin + 20)) { disconnect(errors::invalid_encryption_constant, op_encryption, 2); @@ -3167,7 +3167,7 @@ namespace libtorrent recv_buffer = m_recv_buffer.get(); int packet_size = recv_buffer[0]; - const char protocol_string[] = "\x13" "BitTorrent protocol"; + static const char protocol_string[] = "\x13" "BitTorrent protocol"; if (packet_size != 19 || memcmp(recv_buffer.begin, protocol_string, 20) != 0) diff --git a/src/http_tracker_connection.cpp b/src/http_tracker_connection.cpp index 6827ccf2c..cf891bf92 100644 --- a/src/http_tracker_connection.cpp +++ b/src/http_tracker_connection.cpp @@ -115,7 +115,7 @@ namespace libtorrent if (0 == (tracker_req().kind & tracker_request::scrape_request)) { - const char* event_string[] = {"completed", "started", "stopped", "paused"}; + static const char* event_string[] = {"completed", "started", "stopped", "paused"}; char str[1024]; const bool stats = tracker_req().send_stats; diff --git a/src/upnp.cpp b/src/upnp.cpp index f78ac9824..b71704ca3 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -129,7 +129,7 @@ void upnp::log(char const* msg, mutex::scoped_lock& l) void upnp::discover_device_impl(mutex::scoped_lock& l) { - const char msearch[] = + static const char msearch[] = "M-SEARCH * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "ST:upnp:rootdevice\r\n" diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index 19c66b302..a5e0d820c 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -268,7 +268,7 @@ namespace libtorrent { namespace TORRENT_ASSERT(!m_pc.associated_torrent().expired()); #ifndef TORRENT_DISABLE_LOGGING - char const* names[] = {"request", "data", "dont-have"}; + static char const* names[] = {"request", "data", "dont-have"}; char const* n = ""; if (type >= 0 && type < 3) n = names[type]; m_pc.peer_log(peer_log_alert::outgoing_message, "UT_METADATA" diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index fb5e95bf5..a22a3a530 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -61,7 +61,7 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { namespace { - const char extension_name[] = "ut_pex"; + static const char extension_name[] = "ut_pex"; enum { From 605227d9da992b5552e9396be5c575c5476982e7 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 23 Jan 2017 20:13:19 -0500 Subject: [PATCH 5/9] add test for get_cache_info --- include/libtorrent/settings_pack.hpp | 6 +++- test/test_session.cpp | 46 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/libtorrent/settings_pack.hpp b/include/libtorrent/settings_pack.hpp index ee4e3d6a7..93a835bda 100644 --- a/include/libtorrent/settings_pack.hpp +++ b/include/libtorrent/settings_pack.hpp @@ -45,9 +45,13 @@ POSSIBILITY OF SUCH DAMAGE. // OVERVIEW // // You have some control over session configuration through the session::apply_settings() -// member function. To change one or more configuration options, create a settings_pack. +// member function. To change one or more configuration options, create a settings_pack // object and fill it with the settings to be set and pass it in to session::apply_settings(). // +// The settings_pack object is a collection of settings updates that are applied +// to the session when passed to session::apply_settings(). It's empty when +// constructed. +// // You have control over proxy and authorization settings and also the user-agent // that will be sent to the tracker. The user-agent will also be used to identify the // client with other peers. diff --git a/test/test_session.cpp b/test/test_session.cpp index b84f105b2..ecb5f6e3b 100644 --- a/test/test_session.cpp +++ b/test/test_session.cpp @@ -154,6 +154,52 @@ TORRENT_TEST(paused_session) TEST_CHECK(!h.status().paused); } +TORRENT_TEST(get_cache_info) +{ + lt::session s(settings()); + lt::cache_status ret; + s.get_cache_info(&ret); + + TEST_CHECK(ret.pieces.empty()); +#ifndef TORRENT_NO_DEPRECATE + TEST_EQUAL(ret.blocks_written, 0); + TEST_EQUAL(ret.writes, 0); + TEST_EQUAL(ret.blocks_read, 0); + TEST_EQUAL(ret.blocks_read_hit, 0); + TEST_EQUAL(ret.reads, 0); + TEST_EQUAL(ret.queued_bytes, 0); + TEST_EQUAL(ret.cache_size, 0); + TEST_EQUAL(ret.write_cache_size, 0); + TEST_EQUAL(ret.read_cache_size, 0); + TEST_EQUAL(ret.pinned_blocks, 0); + TEST_EQUAL(ret.total_used_buffers, 0); + TEST_EQUAL(ret.average_read_time, 0); + TEST_EQUAL(ret.average_write_time, 0); + TEST_EQUAL(ret.average_hash_time, 0); + TEST_EQUAL(ret.average_job_time, 0); + TEST_EQUAL(ret.cumulative_job_time, 0); + TEST_EQUAL(ret.cumulative_read_time, 0); + TEST_EQUAL(ret.cumulative_write_time, 0); + TEST_EQUAL(ret.cumulative_hash_time, 0); + TEST_EQUAL(ret.total_read_back, 0); + TEST_EQUAL(ret.read_queue_size, 0); + TEST_EQUAL(ret.blocked_jobs, 0); + TEST_EQUAL(ret.queued_jobs, 0); + TEST_EQUAL(ret.peak_queued, 0); + TEST_EQUAL(ret.pending_jobs, 0); + TEST_EQUAL(ret.num_jobs, 0); + TEST_EQUAL(ret.num_read_jobs, 0); + TEST_EQUAL(ret.num_write_jobs, 0); + TEST_EQUAL(ret.arc_mru_size, 0); + TEST_EQUAL(ret.arc_mru_ghost_size, 0); + TEST_EQUAL(ret.arc_mfu_size, 0); + TEST_EQUAL(ret.arc_mfu_ghost_size, 0); + TEST_EQUAL(ret.arc_write_size, 0); + TEST_EQUAL(ret.arc_volatile_size, 0); + TEST_EQUAL(ret.num_writing_threads, 0); +#endif +} + #if __cplusplus >= 201103L template From 62db98ca0908f62ce80bd7d6a272c00d6d000e23 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 23 Jan 2017 20:33:52 -0500 Subject: [PATCH 6/9] add missing min_memory_usage() and high_performance_seed() settings presets to python --- ChangeLog | 1 + bindings/python/src/session.cpp | 60 +++++++++++++++++++++------------ bindings/python/test.py | 14 ++++++++ 3 files changed, 53 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0ee4bf20..b6bb4054f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * add missing min_memory_usage() and high_performance_seed() settings presets to python * fix stat cache issue that sometimes would produce incorrect resume data * storage optimization to peer classes * fix torrent name in alerts of builds with deprecated functions diff --git a/bindings/python/src/session.cpp b/bindings/python/src/session.cpp index 3e51ab0c7..4e4aff1df 100644 --- a/bindings/python/src/session.cpp +++ b/bindings/python/src/session.cpp @@ -140,6 +140,29 @@ namespace } } + dict make_dict(lt::settings_pack const& sett) + { + dict ret; + for (int i = settings_pack::string_type_base; + i < settings_pack::max_string_setting_internal; ++i) + { + ret[name_for_setting(i)] = sett.get_str(i); + } + + for (int i = settings_pack::int_type_base; + i < settings_pack::max_int_setting_internal; ++i) + { + ret[name_for_setting(i)] = sett.get_int(i); + } + + for (int i = settings_pack::bool_type_base; + i < settings_pack::max_bool_setting_internal; ++i) + { + ret[name_for_setting(i)] = sett.get_bool(i); + } + return ret; + } + boost::shared_ptr make_session(boost::python::dict sett, int flags) { settings_pack p; @@ -181,25 +204,21 @@ namespace allow_threading_guard guard; sett = ses.get_settings(); } - dict ret; - for (int i = settings_pack::string_type_base; - i < settings_pack::max_string_setting_internal; ++i) - { - ret[name_for_setting(i)] = sett.get_str(i); - } + return make_dict(sett); + } - for (int i = settings_pack::int_type_base; - i < settings_pack::max_int_setting_internal; ++i) - { - ret[name_for_setting(i)] = sett.get_int(i); - } + dict min_memory_usage_wrapper() + { + settings_pack ret; + min_memory_usage(ret); + return make_dict(ret); + } - for (int i = settings_pack::bool_type_base; - i < settings_pack::max_bool_setting_internal; ++i) - { - ret[name_for_setting(i)] = sett.get_bool(i); - } - return ret; + dict high_performance_seed_wrapper() + { + settings_pack ret; + high_performance_seed(ret); + return make_dict(ret); } #ifndef BOOST_NO_EXCEPTIONS @@ -962,11 +981,8 @@ 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); + def("high_performance_seed", high_performance_seed_wrapper); + def("min_memory_usage", min_memory_usage_wrapper); class_("stats_metric") .def_readonly("name", &stats_metric::name) diff --git a/bindings/python/test.py b/bindings/python/test.py index 0dce7dfcd..ab76e3c9a 100644 --- a/bindings/python/test.py +++ b/bindings/python/test.py @@ -252,6 +252,20 @@ class test_session(unittest.TestCase): self.assertEqual(s.get_settings()['num_want'], 66) self.assertEqual(s.get_settings()['user_agent'], 'test123') + def test_min_memory_preset(self): + min_mem = lt.min_memory_usage() + print(min_mem) + + self.assertTrue('connection_speed' in min_mem) + self.assertTrue('file_pool_size' in min_mem) + + def test_seed_mode_preset(self): + seed_mode = lt.high_performance_seed() + print(seed_mode) + + self.assertTrue('alert_queue_size' in seed_mode) + self.assertTrue('connection_speed' in seed_mode) + self.assertTrue('file_pool_size' in seed_mode) if __name__ == '__main__': print(lt.__version__) From b19cb7bd8732322d6dd09bd3c761357e00092a33 Mon Sep 17 00:00:00 2001 From: arvidn Date: Tue, 24 Jan 2017 19:12:47 -0500 Subject: [PATCH 7/9] fixed finished-time calculation --- ChangeLog | 1 + src/torrent.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6bb4054f..ac9e663e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * fixed finished-time calculation * add missing min_memory_usage() and high_performance_seed() settings presets to python * fix stat cache issue that sometimes would produce incorrect resume data * storage optimization to peer classes diff --git a/src/torrent.cpp b/src/torrent.cpp index e91afbc01..1c7f92f19 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -9535,7 +9535,7 @@ namespace libtorrent } m_became_seed = clamped_subtract(m_became_seed, seconds); - if (m_finished_time < seconds && is_finished()) + if (m_became_finished < seconds && is_finished()) { int lost_seconds = seconds - m_became_finished; m_finished_time += lost_seconds; From ba9fae8e1f74727f114f555e56ec26b3bfc27d38 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 25 Jan 2017 23:42:59 -0500 Subject: [PATCH 8/9] fix issue with unloading torrents (#1624) fix issue with unloading torrents --- ChangeLog | 1 + include/libtorrent/add_torrent_params.hpp | 3 +++ src/file_storage.cpp | 2 +- src/session_handle.cpp | 1 + src/session_impl.cpp | 2 ++ src/torrent.cpp | 11 +++++++++++ 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ac9e663e0..6b16c897b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * fix issue related to unloading torrents * fixed finished-time calculation * add missing min_memory_usage() and high_performance_seed() settings presets to python * fix stat cache issue that sometimes would produce incorrect resume data diff --git a/include/libtorrent/add_torrent_params.hpp b/include/libtorrent/add_torrent_params.hpp index a52ad0e9e..db39bbabf 100644 --- a/include/libtorrent/add_torrent_params.hpp +++ b/include/libtorrent/add_torrent_params.hpp @@ -311,6 +311,9 @@ namespace libtorrent // On windows this path (and other paths) are interpreted as UNC // paths. This means they must use backslashes as directory separators // and may not contain the special directories "." or "..". + // + // Setting this to an absolute path is slightly more performant than a + // relative path. std::string save_path; // The optional parameter, ``resume_data`` can be given if up to date diff --git a/src/file_storage.cpp b/src/file_storage.cpp index d904da436..9f1248cbc 100644 --- a/src/file_storage.cpp +++ b/src/file_storage.cpp @@ -850,7 +850,7 @@ namespace libtorrent if (index >= int(m_file_hashes.size())) return sha1_hash(0); return sha1_hash(m_file_hashes[index]); } - + std::string const& file_storage::symlink(internal_file_entry const& fe) const { TORRENT_ASSERT_PRECOND(fe.symlink_index < int(m_symlinks.size())); diff --git a/src/session_handle.cpp b/src/session_handle.cpp index b3ab55c78..0930ab732 100644 --- a/src/session_handle.cpp +++ b/src/session_handle.cpp @@ -172,6 +172,7 @@ namespace libtorrent void session_handle::async_add_torrent(add_torrent_params const& params) { add_torrent_params* p = new add_torrent_params(params); + p->save_path = complete(p->save_path); #ifndef TORRENT_NO_DEPRECATE if (params.tracker_url) { diff --git a/src/session_impl.cpp b/src/session_impl.cpp index c1543974e..f7a7112b6 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4794,6 +4794,8 @@ retry: { params->url.clear(); params->ti = boost::shared_ptr(j->buffer.torrent_file); + TORRENT_ASSERT(params->ti->is_valid()); + TORRENT_ASSERT(params->ti->num_files() > 0); handle = add_torrent(*params, ec); } diff --git a/src/torrent.cpp b/src/torrent.cpp index 1c7f92f19..36382e1bc 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -7163,6 +7163,7 @@ namespace libtorrent } m_verified.resize(m_torrent_file->num_pieces(), false); + m_verifying.resize(m_torrent_file->num_pieces(), false); } } @@ -8301,6 +8302,8 @@ namespace libtorrent // returns true if this torrent is interested in connecting to more peers bool torrent::want_peers() const { + if (m_should_be_loaded == false) return false; + // if all our connection slots are taken, we can't connect to more if (m_connections.size() >= m_max_connections) return false; @@ -10236,6 +10239,8 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); INVARIANT_CHECK; + if (m_should_be_loaded == false) return; + boost::weak_ptr self(shared_from_this()); #ifndef TORRENT_DISABLE_EXTENSIONS @@ -11383,6 +11388,12 @@ namespace libtorrent TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(want_peers()); + if (m_should_be_loaded == false) + { + update_want_peers(); + return false; + } + torrent_state st = get_peer_list_state(); need_peer_list(); torrent_peer* p = m_peer_list->connect_one_peer(m_ses.session_time(), &st); From cca5ab83688459ad1d19709c98da76af8e4df3ca Mon Sep 17 00:00:00 2001 From: arvidn Date: Thu, 26 Jan 2017 23:39:56 -0500 Subject: [PATCH 9/9] fix integer overflow --- src/peer_connection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 32527a5bb..d3b40967e 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5134,7 +5134,7 @@ namespace libtorrent // only add new piece-chunks if the send buffer is small enough // otherwise there will be no end to how large it will be! - int buffer_size_watermark = int(m_uploaded_last_second + int buffer_size_watermark = int(boost::int64_t(m_uploaded_last_second) * m_settings.get_int(settings_pack::send_buffer_watermark_factor) / 100); if (buffer_size_watermark < m_settings.get_int(settings_pack::send_buffer_low_watermark))