From 32d368e1ce9b395c578fe4c80bdb3c75c7c5a036 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 12 Oct 2014 18:16:46 +0000 Subject: [PATCH] merged changes from RC_1_0 --- ChangeLog | 1 + include/libtorrent/torrent.hpp | 1 + src/bt_peer_connection.cpp | 9 ++++++++- src/peer_connection.cpp | 16 +++++++++------- src/torrent.cpp | 8 -------- test/swarm_suite.cpp | 6 ++++++ test/web_seed_suite.hpp | 1 + 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32c68346c..8ac70d50f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ * almost completely changed the storage interface (for custom storage) * added support for hashing pieces in multiple threads + * fix protocol race-condition in super seeding mode * support read-only DHT nodes * remove unused partial hash DHT lookups * remove potentially privacy leaking extension (non-anonymous mode) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 48dafc92c..befcc2e91 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -250,6 +250,7 @@ namespace libtorrent sha1_hash const& info_hash() const { + TORRENT_ASSERT(m_torrent_file); static sha1_hash empty; return m_torrent_file ? m_torrent_file->info_hash() : empty; } diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 143bd6e2b..3312a51ae 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -823,6 +823,13 @@ namespace libtorrent ptr += 20; #ifdef TORRENT_VERBOSE_LOGGING + { + char hex_pid[41]; + to_hex((char const*)&m_our_peer_id[0], 20, hex_pid); + hex_pid[40] = 0; + peer_log(">>> sent peer_id: %s client: %s" + , hex_pid, identify_client(m_our_peer_id).c_str()); + } peer_log("==> HANDSHAKE [ ih: %s ]", to_hex(ih.to_string()).c_str()); #endif send_buffer(handshake, sizeof(handshake)); @@ -3275,7 +3282,7 @@ namespace libtorrent if (is_print(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i]; else ascii_pid[i] = '.'; } - peer_log("<<< received peer_id: %s client: %s\nas ascii: %s\n" + peer_log("<<< received peer_id: %s client: %s ascii: \"%s\"" , hex_pid, identify_client(peer_id(recv_buffer.begin)).c_str(), ascii_pid); } #endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index e6cfd3b71..43f877080 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -1905,13 +1905,6 @@ namespace libtorrent TORRENT_ASSERT(t); choke_this_peer(); - - if (t->super_seeding()) - { - // maybe we need to try another piece, to see if the peer - // is interested in us then - superseed_piece(-1, t->get_piece_to_super_seed(m_have_piece)); - } } void peer_connection::choke_this_peer() @@ -4787,6 +4780,15 @@ namespace libtorrent send_block_requests(); } + if (t->super_seeding() + && !m_peer_interested + && m_became_uninterested + seconds(10) < now) + { + // maybe we need to try another piece, to see if the peer + // become interested in us then + superseed_piece(-1, t->get_piece_to_super_seed(m_have_piece)); + } + on_tick(); if (is_disconnecting()) return; diff --git a/src/torrent.cpp b/src/torrent.cpp index 28751d93c..0a100fb48 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -4764,14 +4764,6 @@ namespace libtorrent avail_vec.push_back(i); } - if (min_availability > 1) - { - // if the minimum availability is 2 or more, - // we shouldn't be super seeding any more - super_seeding(false); - return -1; - } - return avail_vec[random() % avail_vec.size()]; } diff --git a/test/swarm_suite.cpp b/test/swarm_suite.cpp index 89f24e260..b94b4af55 100644 --- a/test/swarm_suite.cpp +++ b/test/swarm_suite.cpp @@ -146,6 +146,12 @@ void test_swarm(int flags) torrent_status st2 = tor2.status(); torrent_status st3 = tor3.status(); + if (flags & super_seeding) + { + TEST_CHECK(st1.is_seeding); + TEST_CHECK(st1.super_seeding); + } + if (st2.progress < 1.f && st2.progress > 0.5f) { sum_dl_rate2 += st2.download_payload_rate; diff --git a/test/web_seed_suite.hpp b/test/web_seed_suite.hpp index 50c0ca2a3..d3b2d2103 100644 --- a/test/web_seed_suite.hpp +++ b/test/web_seed_suite.hpp @@ -29,6 +29,7 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + #include "test.hpp" int EXPORT run_http_suite(int proxy, char const* protocol