forked from premiere/premiere-libtorrent
added smooth_connect and turned it on by default
This commit is contained in:
parent
7f981ece6c
commit
9aa09d384c
|
@ -4304,6 +4304,7 @@ session_settings
|
|||
bool no_connect_privileged_ports;
|
||||
int alert_queue_size;
|
||||
int max_metadata_size;
|
||||
bool smooth_connects;
|
||||
};
|
||||
|
||||
``version`` is automatically set to the libtorrent version you're using
|
||||
|
@ -5137,6 +5138,12 @@ defaults to 1000.
|
|||
``max_metadata_size`` is the maximum allowed size (in bytes) to be received
|
||||
by the metadata extension, i.e. magnet links. It defaults to 1 MiB.
|
||||
|
||||
``smooth_connects`` is true by default, which means the number of connection
|
||||
attempts per second may be limited to below the ``connection_speed``, in case
|
||||
we're close to bump up against the limit of number of connections. The intention
|
||||
of this setting is to more evenly distribute our connection attempts over time,
|
||||
instead of attempting to connectin in batches, and timing them out in batches.
|
||||
|
||||
pe_settings
|
||||
===========
|
||||
|
||||
|
|
|
@ -263,6 +263,7 @@ namespace libtorrent
|
|||
, no_connect_privileged_ports(true)
|
||||
, alert_queue_size(1000)
|
||||
, max_metadata_size(1024*1024)
|
||||
, smooth_connects(true)
|
||||
{}
|
||||
|
||||
// libtorrent version. Used for forward binary compatibility
|
||||
|
@ -1046,6 +1047,10 @@ namespace libtorrent
|
|||
// the max allowed size for metadata received by the
|
||||
// ut_metadata extension (i.e. magnet links)
|
||||
int max_metadata_size;
|
||||
|
||||
// attempt to smooth out connects to avoid getting spikes in
|
||||
// opening connections and timing out connections
|
||||
bool smooth_connects;
|
||||
};
|
||||
|
||||
#ifndef TORRENT_DISABLE_DHT
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue