diff --git a/src/policy.cpp b/src/policy.cpp index 1e2ee41a7..f3f81676b 100644 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -847,8 +847,12 @@ namespace libtorrent if (int(m_peers.size()) >= m_torrent->settings().max_peerlist_size) { - c.disconnect(errors::too_many_connections); - return false; + erase_peers(); + if (int(m_peers.size()) >= m_torrent->settings().max_peerlist_size) + { + c.disconnect(errors::too_many_connections); + return false; + } } #if TORRENT_USE_IPV6 diff --git a/src/torrent.cpp b/src/torrent.cpp index 3f0a4bc11..c3bac3e59 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5173,7 +5173,13 @@ namespace libtorrent } #endif if (!m_policy.new_connection(*p, m_ses.session_time())) + { +#if defined TORRENT_LOGGING + (*m_ses.m_logger) << time_now_string() << " CLOSING CONNECTION " + << p->remote() << " policy::new_connection returned false (i.e. peer list full)\n"; +#endif return false; + } } TORRENT_CATCH (std::exception& e) {