From 2705859bb4d6234b7481236fcb5fea321df09ef0 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 27 Apr 2010 18:22:59 +0000 Subject: [PATCH] fixed bug where trackers wouldn't be retried if they failed --- ChangeLog | 1 + examples/client_test.cpp | 2 +- include/libtorrent/torrent_info.hpp | 7 +++++++ src/torrent.cpp | 16 ++++++++-------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f1d330b4..0b55297c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed bug where trackers wouldn't be retried if they failed * slight performance fix in disk elevator algorithm * fixed potential issue where a piece could be checked twice * fixed build issue on windows related to GetCompressedSize() diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 274698ef0..2fb5aed4d 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1432,7 +1432,7 @@ int main(int argc, char* argv[]) snprintf(str, sizeof(str), "%2d %-55s fails: %-3d %s %s \"%s\" %s\n" , i->tier, i->url.c_str(), i->fails, i->verified?"OK ":"- " , i->updating?"updating" - :!i->verified?"" + :!i->will_announce(now)?"" :to_string(total_seconds(i->next_announce - now), 8).c_str() , i->last_error ? i->last_error.message().c_str() : "" , i->message.c_str()); diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index 9013805fd..f7fc751bb 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -149,6 +149,13 @@ namespace libtorrent void failed(int retry_interval = 0); + bool will_announce(ptime now) const + { + return now <= next_announce + && (fails < fail_limit || fail_limit == 0) + && !updating; + } + bool can_announce(ptime now) const { return now >= next_announce diff --git a/src/torrent.cpp b/src/torrent.cpp index afecbcce3..02d5f5ea5 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5477,14 +5477,14 @@ namespace libtorrent if (i->is_working()) { tier = i->tier; found_working = false; } if (i->fails >= i->fail_limit && i->fail_limit != 0) continue; if (i->updating) { found_working = true; continue; } - if (i->is_working()) - { - ptime next_tracker_announce = (std::max)(i->next_announce, i->min_announce); - if (!i->updating && next_tracker_announce < next_announce) next_announce = next_tracker_announce; - found_working = true; - if (!settings().announce_to_all_trackers - && !settings().announce_to_all_tiers) break; - } + ptime next_tracker_announce = (std::max)(i->next_announce, i->min_announce); + if (!i->updating + && next_tracker_announce < next_announce + && (!found_working || i->is_working())) + next_announce = next_tracker_announce; + if (i->is_working()) found_working = true; + if (!settings().announce_to_all_trackers + && !settings().announce_to_all_tiers) break; } if (next_announce == max_time()) return;