Skip to content

Commit

Permalink
fix DHT announce timer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jan 10, 2022
1 parent 017d898 commit 736390e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
* fix DHT announce timer issue

* 2.0.5 released

* on windows, explicitly flush memory mapped files periodically
Expand Down
26 changes: 10 additions & 16 deletions src/session_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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); });
Expand Down

0 comments on commit 736390e

Please sign in to comment.