From eeda665d068f474872ca05ace6964442bdb3d988 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 13 Apr 2010 04:37:39 +0000 Subject: [PATCH] report tracker errors in the tracker list --- docs/manual.rst | 10 ++++++++++ examples/client_test.cpp | 6 ++++-- include/libtorrent/torrent_info.hpp | 8 ++++++++ src/torrent.cpp | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index ac0a33926..005403f05 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -1804,6 +1804,10 @@ ones with lower tier will always be tried before the one with higher tier number int next_announce_in() const; int min_announce_in() const; + error_code last_error; + + std::string message; + boost::uint8_t tier; boost::uint8_t fail_limit; boost::uint8_t fails; @@ -1827,6 +1831,12 @@ ones with lower tier will always be tried before the one with higher tier number this tracker. ``min_announce_in()`` returns the number of seconds until we are allowed to force another tracker update with this tracker. +If the last time this tracker was contacted failed, ``last_error`` is the error +code describing what error occurred. + +If the last time this tracker was contacted, the tracker returned a warning +or error message, ``message`` contains that message. + ``fail_limit`` is the max number of failures to announce to this tracker in a row, before this tracker is not used anymore. diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 085730eab..bba0c48fa 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1428,11 +1428,13 @@ int main(int argc, char* argv[]) for (std::vector::iterator i = tr.begin() , end(tr.end()); i != end; ++i) { - snprintf(str, sizeof(str), "%2d %-55s fails: %-3d %s %s\n" + 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?"" - :to_string(total_seconds(i->next_announce - now), 8).c_str()); + :to_string(total_seconds(i->next_announce - now), 8).c_str() + , i->last_error ? i->last_error.message().c_str() : "" + , i->message.c_str()); out += str; } } diff --git a/include/libtorrent/torrent_info.hpp b/include/libtorrent/torrent_info.hpp index bb84053ff..9013805fd 100644 --- a/include/libtorrent/torrent_info.hpp +++ b/include/libtorrent/torrent_info.hpp @@ -97,6 +97,14 @@ namespace libtorrent // no announces before this time ptime min_announce; + // if this tracker failed the last time it was contacted + // this error code specifies what error occurred + error_code last_error; + + // if this tracker has returned an error or warning message + // that message is stored here + std::string message; + boost::uint8_t tier; // the number of times this tracker can fail // in a row before it's removed. 0 means unlimited diff --git a/src/torrent.cpp b/src/torrent.cpp index 1dad5db07..22479ecff 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -6459,6 +6459,8 @@ namespace libtorrent if (ae) { ae->failed(retry_interval); + ae->last_error = ec; + ae->message = msg; int tracker_index = ae - &m_trackers[0]; deprioritize_tracker(tracker_index); }