fix DHT announce timer issue

This commit is contained in:
arvidn
2022-01-07 22:04:10 -05:00
committed by Arvid Norberg
parent 017d8988ea
commit 736390e1f6
2 changed files with 12 additions and 16 deletions

View File

@ -1,3 +1,5 @@
* fix DHT announce timer issue
* 2.0.5 released
* on windows, explicitly flush memory mapped files periodically

View File

@ -3795,22 +3795,7 @@ namespace {
TORRENT_ASSERT(m_dht);
// announce to DHT every 15 minutes
int delay = std::max(m_settings.get_int(settings_pack::dht_announce_interval)
/ std::max(int(m_torrents.size()), 1), 1);
if (!m_dht_torrents.empty())
{
// we have prioritized torrents that need
// an initial DHT announce. Don't wait too long
// until we announce those.
delay = std::min(4, delay);
}
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
m_dht_announce_timer.expires_after(seconds(delay));
m_dht_announce_timer.async_wait([this](error_code const& err)
{ wrap(&session_impl::on_dht_announce, err); });
update_dht_announce_interval();
if (!m_dht_torrents.empty())
{
@ -6557,6 +6542,15 @@ namespace {
ADD_OUTSTANDING_ASYNC("session_impl::on_dht_announce");
int delay = std::max(m_settings.get_int(settings_pack::dht_announce_interval)
/ std::max(int(m_torrents.size()), 1), 1);
if (!m_dht_torrents.empty())
{
// we have prioritized torrents that need
// an initial DHT announce. Don't wait too long
// until we announce those.
delay = std::min(4, delay);
}
m_dht_announce_timer.expires_after(seconds(delay));
m_dht_announce_timer.async_wait([this](error_code const& e) {
wrap(&session_impl::on_dht_announce, e); });