fix: respect min interval and interval if they exist (#7493)

* fix: parse `min interval` and `interval` if they exist

* fix: account for `interval` and `min interval` during tracker failure

---------

Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
Yat Ho
2025-10-27 23:44:29 +08:00
committed by GitHub
parent 4bd9aa9b06
commit 4f26b62908

View File

@@ -871,7 +871,7 @@ bool isUnregistered(char const* errmsg)
return std::any_of(std::begin(Keys), std::end(Keys), [&lower](auto const& key) { return tr_strv_contains(lower, key); }); return std::any_of(std::begin(Keys), std::end(Keys), [&lower](auto const& key) { return tr_strv_contains(lower, key); });
} }
void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e) void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e, time_t interval = {})
{ {
using namespace announce_helpers; using namespace announce_helpers;
@@ -902,7 +902,7 @@ void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
else else
{ {
/* schedule a reannounce */ /* schedule a reannounce */
auto const interval = current_tracker->getRetryInterval(); interval = std::max(interval, current_tracker->getRetryInterval());
tr_logAddWarnTier( tr_logAddWarnTier(
tier, tier,
fmt::format( fmt::format(
@@ -1019,6 +1019,17 @@ void tr_announcer_impl::onAnnounceDone(
(!std::empty(response.errmsg) ? response.errmsg.c_str() : "none"), (!std::empty(response.errmsg) ? response.errmsg.c_str() : "none"),
(!std::empty(response.warning) ? response.warning.c_str() : "none"))); (!std::empty(response.warning) ? response.warning.c_str() : "none")));
// https://github.com/arvidn/libtorrent/issues/5084#issuecomment-688516452
if (response.min_interval != 0)
{
tier->announceMinIntervalSec = response.min_interval;
}
if (response.interval != 0)
{
tier->announceIntervalSec = response.interval;
}
tier->lastAnnounceTime = now; tier->lastAnnounceTime = now;
tier->lastAnnounceTimedOut = response.did_timeout; tier->lastAnnounceTimedOut = response.did_timeout;
tier->lastAnnounceSucceeded = false; tier->lastAnnounceSucceeded = false;
@@ -1049,7 +1060,11 @@ void tr_announcer_impl::onAnnounceDone(
publishError(tier, response.errmsg); publishError(tier, response.errmsg);
} }
on_announce_error(tier, response.errmsg.c_str(), event); on_announce_error(
tier,
response.errmsg.c_str(),
event,
response.interval > time_t{} ? response.interval : response.min_interval);
} }
else else
{ {
@@ -1095,16 +1110,6 @@ void tr_announcer_impl::onAnnounceDone(
tier->last_announce_str = _("Success"); tier->last_announce_str = _("Success");
} }
if (response.min_interval != 0)
{
tier->announceMinIntervalSec = response.min_interval;
}
if (response.interval != 0)
{
tier->announceIntervalSec = response.interval;
}
if (!std::empty(response.pex)) if (!std::empty(response.pex))
{ {
publishPeersPex(tier, response.pex); publishPeersPex(tier, response.pex);