feat: stop announcing on not-registered tracker error (#2708)
Fixes #2051.
This commit is contained in:
parent
e94ddc82fc
commit
4450973d94
|
@ -927,6 +927,15 @@ struct announce_data
|
||||||
bool is_running_on_success = false;
|
bool is_running_on_success = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool isUnregistered(char const* errmsg)
|
||||||
|
{
|
||||||
|
auto const lower = tr_strlower(errmsg != nullptr ? errmsg : "");
|
||||||
|
|
||||||
|
auto constexpr Keys = std::array<std::string_view, 2>{ "unregistered torrent"sv, "torrent not registered"sv };
|
||||||
|
|
||||||
|
return std::any_of(std::begin(Keys), std::end(Keys), [&lower](auto const& key) { return tr_strvContains(lower, key); });
|
||||||
|
}
|
||||||
|
|
||||||
static void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
|
static void on_announce_error(tr_tier* tier, char const* err, tr_announce_event e)
|
||||||
{
|
{
|
||||||
/* increment the error count */
|
/* increment the error count */
|
||||||
|
@ -942,12 +951,20 @@ static void on_announce_error(tr_tier* tier, char const* err, tr_announce_event
|
||||||
/* switch to the next tracker */
|
/* switch to the next tracker */
|
||||||
current_tracker = tier->useNextTracker();
|
current_tracker = tier->useNextTracker();
|
||||||
|
|
||||||
/* schedule a reannounce */
|
|
||||||
int const interval = current_tracker->getRetryInterval();
|
|
||||||
auto const* const host_cstr = current_tracker->host.c_str();
|
auto const* const host_cstr = current_tracker->host.c_str();
|
||||||
dbgmsg(tier, "Tracker '%s' announce error: %s (Retrying in %d seconds)", host_cstr, err, interval);
|
if (isUnregistered(err))
|
||||||
tr_logAddTorInfo(tier->tor, "Tracker '%s' announce error: %s (Retrying in %d seconds)", host_cstr, err, interval);
|
{
|
||||||
tier_announce_event_push(tier, e, tr_time() + interval);
|
dbgmsg(tier, "Tracker '%s' announce error: %s", host_cstr, err);
|
||||||
|
tr_logAddTorInfo(tier->tor, "Tracker '%s' announce error: %s", host_cstr, err);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* schedule a reannounce */
|
||||||
|
int const interval = current_tracker->getRetryInterval();
|
||||||
|
dbgmsg(tier, "Tracker '%s' announce error: %s (Retrying in %d seconds)", host_cstr, err, interval);
|
||||||
|
tr_logAddTorInfo(tier->tor, "Tracker '%s' announce error: %s (Retrying in %d seconds)", host_cstr, err, interval);
|
||||||
|
tier_announce_event_push(tier, e, tr_time() + interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_announce_done(tr_announce_response const* response, void* vdata)
|
static void on_announce_done(tr_announce_response const* response, void* vdata)
|
||||||
|
|
Loading…
Reference in New Issue