diff --git a/docs/manual.rst b/docs/manual.rst index db6f86189..933b4fe2d 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -3830,8 +3830,9 @@ connection may delay the connection of other peers considerably. unchoke limits are ignored for peers on the local network. ``connection_speed`` is the number of connection attempts that -are made per second. If a number <= 0 is specified, it will default to -200 connections per second. +are made per second. If a number < 0 is specified, it will default to +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 to peers that already have the piece. This is typically not necessary, diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index df48dc9dc..ece050412 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3562,6 +3562,7 @@ namespace libtorrent d = now - (std::max)(m_last_unchoke, m_last_incoming_request); if (!m_connecting && m_requests.empty() + && m_reading_bytes == 0 && !m_choked && m_peer_interested && t && t->is_finished() diff --git a/src/session_impl.cpp b/src/session_impl.cpp index b51285fc5..b269d1a08 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -1066,7 +1066,7 @@ namespace aux { && m_auto_manage_time_scaler > 2) m_auto_manage_time_scaler = 2; 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) { @@ -1467,7 +1467,12 @@ namespace aux { if (reject) { - // TODO: post alert + if (m_alerts.should_post()) + { + 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) (*m_logger) << "number of connections limit exceeded (conns: " << num_connections() << ", limit: " << max_connections() @@ -1976,13 +1981,14 @@ namespace aux { // this loop will "hand out" max(connection_speed // , half_open.free_slots()) to the torrents, in a // 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(); if (!m_torrents.empty() && free_slots > -m_half_open.limit() && num_connections() < m_max_connections - && !m_abort) + && !m_abort + && m_settings.connection_speed > 0) { // this is the maximum number of connections we will // attempt this tick