include tracker message in tracker_alert

This commit is contained in:
Arvid Norberg 2015-02-21 22:45:45 +00:00
parent 89055c4c7a
commit f364fe7beb
3 changed files with 15 additions and 17 deletions

View File

@ -402,14 +402,14 @@ namespace libtorrent
torrent_status::state_t prev_state; torrent_status::state_t prev_state;
}; };
// This alert is generated on tracker time outs, premature disconnects, invalid response or // This alert is generated on tracker time outs, premature disconnects,
// a HTTP response other than "200 OK". From the alert you can get the handle to the torrent // invalid response or a HTTP response other than "200 OK". From the alert
// the tracker belongs to. // 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. // The ``times_in_row`` member says how many times in a row this tracker has
// ``status_code`` is the code returned from the HTTP server. 401 means the tracker needs // failed. ``status_code`` is the code returned from the HTTP server. 401
// authentication, 404 means not found etc. If the tracker timed out, the code will be set // means the tracker needs authentication, 404 means not found etc. If the
// to 0. // tracker timed out, the code will be set to 0.
struct TORRENT_EXPORT tracker_error_alert: tracker_alert struct TORRENT_EXPORT tracker_error_alert: tracker_alert
{ {
// internal // internal
@ -439,9 +439,9 @@ namespace libtorrent
std::string msg; std::string msg;
}; };
// This alert is triggered if the tracker reply contains a warning field. Usually this // This alert is triggered if the tracker reply contains a warning field.
// means that the tracker announce was successful, but the tracker has a message to // Usually this means that the tracker announce was successful, but the
// the client. // tracker has a message to the client.
struct TORRENT_EXPORT tracker_warning_alert: tracker_alert struct TORRENT_EXPORT tracker_warning_alert: tracker_alert
{ {
// internal // internal

View File

@ -155,12 +155,9 @@ namespace libtorrent {
std::string tracker_error_alert::message() const std::string tracker_error_alert::message() const
{ {
char ret[400]; char ret[400];
std::string error_message; snprintf(ret, sizeof(ret), "%s (%d) %s \"%s\" (%d)"
if (error) error_message = error.message();
else error_message = msg;
snprintf(ret, sizeof(ret), "%s (%d) %s (%d)"
, tracker_alert::message().c_str(), status_code , 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; return ret;
} }

View File

@ -11506,7 +11506,7 @@ namespace libtorrent
} }
void torrent::tracker_request_error(tracker_request const& r 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) , int retry_interval)
{ {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
@ -11514,7 +11514,8 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
#if defined TORRENT_LOGGING #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 #endif
if (r.kind == tracker_request::announce_request) if (r.kind == tracker_request::announce_request)
{ {