From e07e8b2f98fe19f600a7539e0d0ff0e77a05d36b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 30 Apr 2011 20:05:23 +0000 Subject: [PATCH] fixed connection limit to take web seeds into account as well --- ChangeLog | 1 + src/torrent.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7989209e3..bd20cbee5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -86,6 +86,7 @@ incoming connection * added more detailed instrumentation of the disk I/O thread + * fixed connection limit to take web seeds into account as well * fixed bug when receiving a have message before having the metadata * fixed python bindings build with disabled DHT support * fixed BSD file allocation issue diff --git a/src/torrent.cpp b/src/torrent.cpp index fa761fd64..3164ebe16 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -3861,6 +3861,10 @@ namespace libtorrent TORRENT_ASSERT(!web->resolving); if (web->resolving) return; + if (int(m_connections.size()) >= m_max_connections + || m_ses.num_connections() >= m_ses.max_connections()) + return; + #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING (*m_ses.m_logger) << time_now_string() << " resolving web seed: " << web->url << "\n"; #endif @@ -4003,6 +4007,10 @@ namespace libtorrent if (m_ses.is_aborted()) return; + if (int(m_connections.size()) >= m_max_connections + || m_ses.num_connections() >= m_ses.max_connections()) + return; + tcp::endpoint a(host->endpoint()); using boost::tuples::ignore; @@ -4074,6 +4082,10 @@ namespace libtorrent return; } + if (int(m_connections.size()) >= m_max_connections + || m_ses.num_connections() >= m_ses.max_connections()) + return; + tcp::endpoint a(host->endpoint()); connect_web_seed(web, a); } @@ -6596,7 +6608,11 @@ namespace libtorrent // ---- WEB SEEDS ---- // if we have everything we want we don't need to connect to any web-seed - if (!is_finished() && !m_web_seeds.empty() && m_files_checked) + if (!is_finished() && !m_web_seeds.empty() && m_files_checked + && int(m_connections.size()) < m_max_connections + && int(m_ses.m_connections.size()) < m_ses.max_connections()) + return; + { // keep trying web-seeds if there are any // first find out which web seeds we are connected to