From f364fe7bebd133866b8bbeb7e24c2e1e5f770809 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 21 Feb 2015 22:45:45 +0000 Subject: [PATCH] include tracker message in tracker_alert --- include/libtorrent/alert_types.hpp | 20 ++++++++++---------- src/alert.cpp | 7 ++----- src/torrent.cpp | 5 +++-- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 7d6b2e9b8..766c34a1c 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -402,14 +402,14 @@ namespace libtorrent torrent_status::state_t prev_state; }; - // This alert is generated on tracker time outs, premature disconnects, invalid response or - // a HTTP response other than "200 OK". From the alert you can get the handle to the torrent - // the tracker belongs to. + // This alert is generated on tracker time outs, premature disconnects, + // invalid response or a HTTP response other than "200 OK". From the alert + // you can get the handle to the torrent the tracker belongs to. // - // The ``times_in_row`` member says how many times in a row this tracker has failed. - // ``status_code`` is the code returned from the HTTP server. 401 means the tracker needs - // authentication, 404 means not found etc. If the tracker timed out, the code will be set - // to 0. + // The ``times_in_row`` member says how many times in a row this tracker has + // failed. ``status_code`` is the code returned from the HTTP server. 401 + // means the tracker needs authentication, 404 means not found etc. If the + // tracker timed out, the code will be set to 0. struct TORRENT_EXPORT tracker_error_alert: tracker_alert { // internal @@ -439,9 +439,9 @@ namespace libtorrent std::string msg; }; - // This alert is triggered if the tracker reply contains a warning field. Usually this - // means that the tracker announce was successful, but the tracker has a message to - // the client. + // This alert is triggered if the tracker reply contains a warning field. + // Usually this means that the tracker announce was successful, but the + // tracker has a message to the client. struct TORRENT_EXPORT tracker_warning_alert: tracker_alert { // internal diff --git a/src/alert.cpp b/src/alert.cpp index ba2fc3095..b918f5865 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -155,12 +155,9 @@ namespace libtorrent { std::string tracker_error_alert::message() const { char ret[400]; - std::string error_message; - if (error) error_message = error.message(); - else error_message = msg; - snprintf(ret, sizeof(ret), "%s (%d) %s (%d)" + snprintf(ret, sizeof(ret), "%s (%d) %s \"%s\" (%d)" , tracker_alert::message().c_str(), status_code - , error_message.c_str(), times_in_row); + , error.message().c_str(), msg.c_str(), times_in_row); return ret; } diff --git a/src/torrent.cpp b/src/torrent.cpp index 87ceda944..c98edf8a2 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -11506,7 +11506,7 @@ namespace libtorrent } void torrent::tracker_request_error(tracker_request const& r - , int response_code, error_code const& ec, const std::string& msg + , int response_code, error_code const& ec, std::string const& msg , int retry_interval) { TORRENT_ASSERT(is_single_thread()); @@ -11514,7 +11514,8 @@ namespace libtorrent INVARIANT_CHECK; #if defined TORRENT_LOGGING - debug_log("*** tracker error: (%d) %s %s", ec.value(), ec.message().c_str(), msg.c_str()); + debug_log("*** tracker error: (%d) %s %s", ec.value() + , ec.message().c_str(), msg.c_str()); #endif if (r.kind == tracker_request::announce_request) {