From 5a8037dba2c8b00d327e421e3fa9cb2917f002a4 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 3 Mar 2012 02:29:37 +0000 Subject: [PATCH] added performance alert for address-in-use errors --- docs/manual.rst | 9 ++++++++- include/libtorrent/alert_types.hpp | 2 +- src/alert.cpp | 3 ++- src/peer_connection.cpp | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index 65fd5b2b5..63d54b566 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -6969,7 +6969,8 @@ upload or download rate performance. download_limit_too_low, send_buffer_watermark_too_low, too_many_optimistic_unchoke_slots, - too_high_disk_queue_limit + too_high_disk_queue_limit, + too_few_outgoing_ports }; performance_warning_t warning_code; @@ -7039,6 +7040,12 @@ too_high_disk_queue_limit portions of the cache before allowing peers to download any more, onto the disk write queue. Either lower ``max_queued_disk_bytes`` or increase ``cache_size``. +too_few_outgoing_ports + This is generated if outgoing peer connections are failing because of *address in use* + errors, indicating that ``session_settings::outgoing_ports`` is set and is too small of + a range. Consider not using the ``outgoing_ports`` setting at all, or widen the range to + include more ports. + state_changed_alert ------------------- diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 1816c39b4..de0a07278 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -225,7 +225,7 @@ namespace libtorrent too_many_optimistic_unchoke_slots, bittyrant_with_no_uplimit, too_high_disk_queue_limit, - + too_few_outgoing_ports, num_warnings diff --git a/src/alert.cpp b/src/alert.cpp index 0fcb7bec1..8e445a952 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -119,7 +119,8 @@ namespace libtorrent { "send buffer watermark too low (upload rate will suffer)", "too many optimistic unchoke slots", "using bittyrant unchoker with no upload rate limit set", - "the disk queue limit is too high compared to the cache size. The disk queue eats into the cache size" + "the disk queue limit is too high compared to the cache size. The disk queue eats into the cache size", + "too few ports allowed for outgoing connections" }; return torrent_alert::message() + ": performance warning: " diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index e21292f00..5fae18252 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3603,6 +3603,14 @@ namespace libtorrent torrent_handle handle; if (t) handle = t->get_handle(); + if (ec == error::address_in_use + && m_ses.m_settings.outgoing_ports.first != 0) + { + if (m_ses.m_alerts.should_post()) + m_ses.m_alerts.post_alert(performance_alert( + handle, performance_alert::too_few_outgoing_ports)); + } + if (ec) { if ((error > 1 || ec.category() == socks_category)