From 01c41fadcfaec7aa111885626de457a8a16eeed4 Mon Sep 17 00:00:00 2001 From: arvidn Date: Mon, 29 Jan 2018 00:22:59 +0100 Subject: [PATCH] fix torrent_status::next_announce --- ChangeLog | 1 + examples/client_test.cpp | 5 +++++ include/libtorrent/torrent.hpp | 4 ---- src/torrent.cpp | 11 +++-------- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17b3d1518..955fa7977 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ + * fix torrent_status::next_announce * fix pad-file scalability issue * made coalesce_reads/coalesce_writes settings take effect on linux and windows * restore support for incoming connections over SOCKS5 (disabled by default) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 67035cf18..bb486806f 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -2048,6 +2048,11 @@ int main(int argc, char* argv[]) if (print_trackers) { + snprintf(str, sizeof(str), "next_announce: %4" PRId64 " | current tracker: %s\x1b[K\n" + , boost::int64_t(duration_cast(s.next_announce).count()) + , s.current_tracker.c_str()); + out += str; + pos += 1; std::vector tr = h.trackers(); time_point now = clock_type::now(); for (std::vector::iterator i = tr.begin() diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index cc1ad2eed..968e3d96a 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -730,10 +730,6 @@ namespace libtorrent // immediately void do_connect_boost(); - // returns the absolute time when the next tracker - // announce will take place. - time_point next_announce() const; - // forcefully sets next_announce to the current time void force_tracker_request(time_point, int tracker_idx); void scrape_tracker(int idx, bool user_triggered); diff --git a/src/torrent.cpp b/src/torrent.cpp index 6cc5f992b..adf9e948f 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3768,11 +3768,6 @@ namespace { if (want_peers()) m_ses.prioritize_connections(shared_from_this()); } - time_point torrent::next_announce() const - { - return m_waiting_tracker?m_tracker_timer.expires_at():min_time(); - } - // this is the entry point for the client to force a re-announce. It's // considered a client-initiated announce (as opposed to the regular ones, // issued by libtorrent) @@ -12208,10 +12203,10 @@ namespace { st->download_payload_rate = m_stat.download_payload_rate(); st->upload_payload_rate = m_stat.upload_payload_rate(); - if (m_waiting_tracker && !is_paused()) - st->next_announce = next_announce() - now; - else + if (is_paused() || m_tracker_timer.expires_at() < now) st->next_announce = seconds(0); + else + st->next_announce = m_tracker_timer.expires_at() - now; if (st->next_announce.count() < 0) st->next_announce = seconds(0);