never time out a peer because we're waiting for the disk. allow connection_speed = 0. post an alert when rejecting a peer because of the connection limit

This commit is contained in:
Arvid Norberg
2010-02-06 21:40:55 +00:00
parent 6797a6967b
commit 0dba0f5dcc
3 changed files with 14 additions and 6 deletions

View File

@@ -3830,8 +3830,9 @@ connection may delay the connection of other peers considerably.
unchoke limits are ignored for peers on the local network. unchoke limits are ignored for peers on the local network.
``connection_speed`` is the number of connection attempts that ``connection_speed`` is the number of connection attempts that
are made per second. If a number <= 0 is specified, it will default to are made per second. If a number < 0 is specified, it will default to
200 connections per second. 200 connections per second. If 0 is specified, it means don't make
outgoing connections at all.
``send_redundant_have`` controls if have messages will be sent ``send_redundant_have`` controls if have messages will be sent
to peers that already have the piece. This is typically not necessary, to peers that already have the piece. This is typically not necessary,

View File

@@ -3562,6 +3562,7 @@ namespace libtorrent
d = now - (std::max)(m_last_unchoke, m_last_incoming_request); d = now - (std::max)(m_last_unchoke, m_last_incoming_request);
if (!m_connecting if (!m_connecting
&& m_requests.empty() && m_requests.empty()
&& m_reading_bytes == 0
&& !m_choked && !m_choked
&& m_peer_interested && m_peer_interested
&& t && t->is_finished() && t && t->is_finished()

View File

@@ -1066,7 +1066,7 @@ namespace aux {
&& m_auto_manage_time_scaler > 2) && m_auto_manage_time_scaler > 2)
m_auto_manage_time_scaler = 2; m_auto_manage_time_scaler = 2;
m_settings = s; m_settings = s;
if (m_settings.connection_speed <= 0) m_settings.connection_speed = 200; if (m_settings.connection_speed < 0) m_settings.connection_speed = 200;
if (update_disk_io_thread) if (update_disk_io_thread)
{ {
@@ -1467,7 +1467,12 @@ namespace aux {
if (reject) if (reject)
{ {
// TODO: post alert if (m_alerts.should_post<peer_disconnected_alert>())
{
m_alerts.post_alert(
peer_disconnected_alert(torrent_handle(), endp, peer_id()
, error_code(errors::too_many_connections, get_libtorrent_category())));
}
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING) #if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
(*m_logger) << "number of connections limit exceeded (conns: " (*m_logger) << "number of connections limit exceeded (conns: "
<< num_connections() << ", limit: " << max_connections() << num_connections() << ", limit: " << max_connections()
@@ -1976,13 +1981,14 @@ namespace aux {
// this loop will "hand out" max(connection_speed // this loop will "hand out" max(connection_speed
// , half_open.free_slots()) to the torrents, in a // , half_open.free_slots()) to the torrents, in a
// round robin fashion, so that every torrent is // round robin fashion, so that every torrent is
// equallt likely to connect to a peer // equally likely to connect to a peer
int free_slots = m_half_open.free_slots(); int free_slots = m_half_open.free_slots();
if (!m_torrents.empty() if (!m_torrents.empty()
&& free_slots > -m_half_open.limit() && free_slots > -m_half_open.limit()
&& num_connections() < m_max_connections && num_connections() < m_max_connections
&& !m_abort) && !m_abort
&& m_settings.connection_speed > 0)
{ {
// this is the maximum number of connections we will // this is the maximum number of connections we will
// attempt this tick // attempt this tick