added smooth_connect and turned it on by default

This commit is contained in:
Arvid Norberg
2011-02-16 03:11:55 +00:00
parent 7f981ece6c
commit 9aa09d384c
3 changed files with 20 additions and 0 deletions

View File

@@ -358,6 +358,7 @@ namespace aux {
TORRENT_SETTING(boolean, no_connect_privileged_ports)
TORRENT_SETTING(integer, alert_queue_size)
TORRENT_SETTING(integer, max_metadata_size)
TORRENT_SETTING(integer, smooth_connects)
};
#undef TORRENT_SETTING
@@ -3020,6 +3021,13 @@ namespace aux {
}
}
// this logic is here to smooth out the number of new connection
// attempts over time, to prevent connecting a large number of
// sockets, wait 10 seconds, and then try again
int limit = (std::min)(m_settings.connections_limit - num_connections(), free_slots);
if (m_settings.smooth_connects && max_connections > (limit+1) / 2)
max_connections = (limit+1) / 2;
if (!m_torrents.empty()
&& free_slots > -m_half_open.limit()
&& num_connections() < m_settings.connections_limit