clear tracker errors on success
This commit is contained in:
parent
11014b7efc
commit
b329d579e9
|
@ -1,3 +1,4 @@
|
|||
* clear tracker errors on success
|
||||
* optimize setting with unlimited unchoke slots
|
||||
* fixed restoring of trackers, comment, creation date and created-by in resume data
|
||||
* fix handling of torrents with too large pieces
|
||||
|
|
|
@ -946,6 +946,66 @@ TORRENT_TEST(try_next)
|
|||
TEST_EQUAL(got_announce, true);
|
||||
}
|
||||
|
||||
TORRENT_TEST(clear_error)
|
||||
{
|
||||
// make sure we clear the error from a previous attempt when succeeding
|
||||
// a tracker announce
|
||||
|
||||
int num_announces = 0;
|
||||
std::string last_message;
|
||||
tracker_test(
|
||||
[](lt::add_torrent_params& p, lt::session& ses)
|
||||
{
|
||||
settings_pack pack;
|
||||
// make sure we just listen on a single listen interface
|
||||
pack.set_str(settings_pack::listen_interfaces, "123.0.0.3:0");
|
||||
pack.set_int(settings_pack::min_announce_interval, 1);
|
||||
pack.set_int(settings_pack::tracker_backoff, 1);
|
||||
ses.apply_settings(pack);
|
||||
p.trackers.push_back("http://tracker.com:8080/announce");
|
||||
return 60;
|
||||
},
|
||||
[&](std::string method, std::string req, std::map<std::string, std::string>&)
|
||||
{
|
||||
// don't count the stopped event when shutting down
|
||||
if (req.find("&event=stopped&") != std::string::npos)
|
||||
{
|
||||
return sim::send_response(200, "OK", 2) + "de";
|
||||
}
|
||||
if (num_announces++ == 0)
|
||||
{
|
||||
// the first announce fails
|
||||
return std::string{};
|
||||
}
|
||||
|
||||
// the second announce succeeds, with an empty peer list
|
||||
char response[500];
|
||||
int const size = std::snprintf(response, sizeof(response), "d8:intervali1800e5:peers0:e");
|
||||
return sim::send_response(200, "OK", size) + response;
|
||||
}
|
||||
, [](torrent_handle h) {
|
||||
|
||||
}
|
||||
, [&](torrent_handle h)
|
||||
{
|
||||
std::vector<announce_entry> const tr = h.trackers();
|
||||
TEST_EQUAL(tr.size(), 1);
|
||||
|
||||
std::printf("tracker \"%s\"\n", tr[0].url.c_str());
|
||||
TEST_EQUAL(tr[0].url, "http://tracker.com:8080/announce");
|
||||
TEST_EQUAL(tr[0].endpoints.size(), 1);
|
||||
auto const& aep = tr[0].endpoints[0];
|
||||
std::printf("message: \"%s\" error: \"%s\"\n"
|
||||
, aep.message.c_str(), aep.last_error.message().c_str());
|
||||
TEST_EQUAL(aep.fails, 0);
|
||||
TEST_CHECK(!aep.last_error);
|
||||
TEST_EQUAL(aep.message, "");
|
||||
last_message = aep.message;
|
||||
});
|
||||
TEST_EQUAL(num_announces, 2);
|
||||
TEST_EQUAL(last_message, "");
|
||||
}
|
||||
|
||||
std::shared_ptr<torrent_info> make_torrent(bool priv)
|
||||
{
|
||||
file_storage fs;
|
||||
|
|
|
@ -3233,6 +3233,8 @@ bool is_downloading_state(int const st)
|
|||
aep->min_announce = now + resp.min_interval;
|
||||
aep->updating = false;
|
||||
aep->fails = 0;
|
||||
aep->last_error.clear();
|
||||
aep->message = !resp.warning_message.empty() ? resp.warning_message : std::string();
|
||||
int tracker_index = int(ae - m_trackers.data());
|
||||
m_last_working_tracker = std::int8_t(prioritize_tracker(tracker_index));
|
||||
|
||||
|
|
Loading…
Reference in New Issue