enable all disabled trackers when listen sockets are re-opened

This commit is contained in:
Arvid Norberg 2020-03-05 11:46:04 +01:00 committed by Arvid Norberg
parent 5c869f697c
commit 9bfb108b4f
3 changed files with 21 additions and 0 deletions

View File

@ -1011,6 +1011,10 @@ namespace libtorrent {
std::vector<announce_entry> const& trackers() const
{ return m_trackers; }
// this sets all the "enabled" states on all trackers, giving them
// all one more chance of being tried
void enable_all_trackers();
void replace_trackers(std::vector<announce_entry> const& urls);
// returns true if the tracker was added, and false if it was already

View File

@ -2027,6 +2027,16 @@ namespace aux {
#if TORRENT_USE_I2P
open_new_incoming_i2p_connection();
#endif
// trackers that were not reachable, may have become reachable now.
// so clear the "disabled" flags to let them be tried one more time
// TODO: it would probably be better to do this by having a
// listen-socket "version" number that gets bumped. And instead of
// setting a bool to disable a tracker, we set the version number that
// it was disabled at. This change would affect the ABI in 1.2, so
// should be done in 2.0 or later
for (auto& t : m_torrents)
t.second->enable_all_trackers();
}
void session_impl::reopen_network_sockets(reopen_network_flags_t const options)

View File

@ -6201,6 +6201,13 @@ bool is_downloading_state(int const st)
return m_torrent_file;
}
void torrent::enable_all_trackers()
{
for (announce_entry& ae : m_trackers)
for (announce_endpoint& aep : ae.endpoints)
aep.enabled = true;
}
void torrent::write_resume_data(add_torrent_params& ret) const
{
ret.version = LIBTORRENT_VERSION_NUM;