From a17f4e4e71c925148c5d426776e379a4730c8d0d Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Wed, 1 Sep 2010 03:14:12 +0000 Subject: [PATCH] fixed bug where event=completed would not be sent if it violated the min-interval --- ChangeLog | 2 ++ include/libtorrent/torrent_info.hpp | 8 +------- src/torrent.cpp | 2 +- src/torrent_info.cpp | 12 ++++++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ae196210..ede928591 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,8 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed announce bug where event=completed would not be sent if it violated the + min-announce of the tracker * fixed limitation in rate limiter * fixed build error with boost 1.44 diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 2293158ec..f385924f1 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -160,13 +160,7 @@ namespace libtorrent && !updating; } - bool can_announce(ptime now) const - { - return now >= next_announce - && now >= min_announce - && (fails < fail_limit || fail_limit == 0) - && !updating; - } + bool can_announce(ptime now, bool is_seed) const; bool is_working() const { return fails == 0; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 5522f2a69..7477b8a56 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -1452,7 +1452,7 @@ namespace libtorrent if (ae.tier > tier && !settings().announce_to_all_tiers) break; if (ae.is_working()) { tier = ae.tier; sent_announce = false; } - if (!ae.can_announce(now)) + if (!ae.can_announce(now, is_seed())) { if (ae.is_working()) { diff --git a/src/torrent_info.cpp b/src/torrent_info.cpp index 00c693756..1fa88c14d 100644 --- a/src/torrent_info.cpp +++ b/src/torrent_info.cpp @@ -418,6 +418,18 @@ namespace libtorrent updating = false; } + bool announce_entry::can_announce(ptime now, bool is_seed) const + { + // if we're a seed and we haven't sent a completed + // event, we need to let this announce through + if (is_seed && !complete_sent) return true; + + return now >= next_announce + && now >= min_announce + && (fails < fail_limit || fail_limit == 0) + && !updating; + } + void announce_entry::trim() { while (!url.empty() && is_space(url[0]))