From 7e540a8d5385a898aedb6ed12329cef90d4c9c4f Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 31 May 2007 19:57:15 +0000 Subject: [PATCH] made inactivity time-out configurable --- docs/manual.rst | 25 +++++++++++++++++++++++++ include/libtorrent/session_settings.hpp | 6 ++++++ src/peer_connection.cpp | 8 +++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/docs/manual.rst b/docs/manual.rst index fead2afaa..78ba3c79d 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -2180,6 +2180,11 @@ that will be sent to the tracker. The user-agent is a good way to identify your int max_failcount; int min_reconnect_time; int peer_connect_timeout; + bool ignore_limits_on_local_network; + int connection_speed; + int send_redundant_have; + bool lazy_bitfields; + int inactivity_timeout; bool use_dht_as_fallback; }; @@ -2280,6 +2285,26 @@ The default is 10 seconds. This setting is especially important in case the number of half-open connections are limited, since stale half-open connection may delay the connection of other peers considerably. +``ignore_limits_on_local_network``, if set to true, upload, download and +unchoke limits are ignored for peers on the local network. + +``connection_speed`` is the number of connection attempts that +are made per second. + +``send_redundant_have`` controls if have messages will be sent +to peers that already have the piece. This is typically not necessary, +but it might be necessary for collecting statistics in some cases. +Default is false. + +``lazy_bitfields`` prevents outgoing bitfields from being full. If the +client is seed, a few bits will be set to 0, and later filled in with +have-messages. This is to prevent certain ISPs from stopping people +from seeding. + +``inactivity_timeout``, if a peer is uninteresting and uninterested +for longer than this number of seconds, it will be disconnected. +Default is 10 minutes + ``use_dht_as_fallback`` determines how the DHT is used. If this is true (which it is by default), the DHT will only be used for torrents where all trackers in its tracker list has failed. Either by an explicit error diff --git a/include/libtorrent/session_settings.hpp b/include/libtorrent/session_settings.hpp index 20a2a48a8..1d61782ba 100644 --- a/include/libtorrent/session_settings.hpp +++ b/include/libtorrent/session_settings.hpp @@ -104,6 +104,7 @@ namespace libtorrent , connection_speed(20) , send_redundant_have(false) , lazy_bitfields(true) + , inactivity_timeout(600) #ifndef TORRENT_DISABLE_DHT , use_dht_as_fallback(true) #endif @@ -228,6 +229,11 @@ namespace libtorrent // from stopping people from seeding. bool lazy_bitfields; + // if a peer is uninteresting and uninterested for longer + // than this number of seconds, it will be disconnected. + // default is 10 minutes + int inactivity_timeout; + #ifndef TORRENT_DISABLE_DHT // while this is true, the dht will note be used unless the // tracker is online diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index e70ad8571..28abb9ba0 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -2592,11 +2592,13 @@ namespace libtorrent time_duration d2; d1 = now - m_became_uninterested; d2 = now - m_became_uninteresting; - // TODO: these timeouts should be user settable + time_duration time_limit = seconds( + m_ses.settings().inactivity_timeout); + if (!m_interesting && !m_peer_interested - && d1 > minutes(10) - && d2 > minutes(10)) + && d1 > time_limit + && d2 > time_limit) { return true; }