Skip to content

Commit

Permalink
fixed tracker connections spinning when hostname lookups stall
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Jul 5, 2022
1 parent 3e0f8d8 commit 0aa7657
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* fixed tracker connections spinning when hostname lookups stall
* fixed error in pkg-config file generation in Jamfile
* improve backwards compatibility with loading magnet link resume files
* fix bind-to-device for tracker announces and UPnP
Expand Down
12 changes: 11 additions & 1 deletion src/http_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,17 @@ void http_connection::on_timeout(std::weak_ptr<http_connection> p

// be forgiving of timeout while we're still resolving the hostname
// it may be delayed because we're queued up behind another slow lookup
if (c->m_start_time + (c->m_completion_timeout * (int(c->m_resolving_host) + 1)) <= now)
if (c->m_resolving_host
&& (c->m_start_time + (c->m_completion_timeout * 2) > now))
{
ADD_OUTSTANDING_ASYNC("http_connection::on_timeout");
error_code ec;
c->m_timer.expires_at(c->m_start_time + c->m_completion_timeout * 2, ec);
c->m_timer.async_wait(std::bind(&http_connection::on_timeout, p, _1));
return;
}

if (c->m_start_time + c->m_completion_timeout <= now)
{
// the connection timed out. If we have more endpoints to try, just
// close this connection. The on_connect handler will try the next
Expand Down

0 comments on commit 0aa7657

Please sign in to comment.