From ee5ce50502fbdde3826037fe23c15ca2567f0930 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 10 Sep 2007 01:57:40 +0000 Subject: [PATCH] made max half open connections default to 8 on windows and added query function for that limit on session. --- docs/building.html | 34 +++++++++++++----------- docs/extension_protocol.html | 4 +-- docs/manual.html | 8 ++++-- docs/manual.rst | 9 +++++-- include/libtorrent/aux_/session_impl.hpp | 1 + include/libtorrent/session.hpp | 1 + src/session.cpp | 5 ++++ src/session_impl.cpp | 27 ++++--------------- 8 files changed, 45 insertions(+), 44 deletions(-) diff --git a/docs/building.html b/docs/building.html index 79fd597ba..7926bf451 100644 --- a/docs/building.html +++ b/docs/building.html @@ -215,12 +215,18 @@ with the libtorrent package. -pe-support +openssl @@ -254,18 +260,6 @@ information. -openssl - - - character-set

This setting will only have an affect on windows. Other platforms are expected to support UTF-8.

@@ -292,7 +286,8 @@ sure all build variants will actually compile), you can invoke this command:

 bjam debug release link=shared link=static logging=verbose logging=default \
 logging=none dht-support=on dht-support=logging dht-support=off pe-support=on \
-pe-support=off zlib=shipped zlib=system
+pe-support=off zlib=shipped zlib=system openssl=on openssl=off \
+character-set=ansi character-set=unicode
 
@@ -504,6 +499,13 @@ torrents will be disabled. This will enable verbose logging of the DHT protocol traffic. +TORRENT_DISABLE_ENCRYPTION +This will disable any encryption support and +the openssl dependency that comes with it. +Encryption support is the peer connection +encrypted supported by clients such as +uTorrent, Azureus and KTorrent. +

If you experience that libtorrent uses unreasonable amounts of cpu, it will diff --git a/docs/extension_protocol.html b/docs/extension_protocol.html index 52fae31d5..1de9cf9f3 100644 --- a/docs/extension_protocol.html +++ b/docs/extension_protocol.html @@ -141,8 +141,8 @@ client than relying on the peer id encoding. A string containing the compact representation of the ip address this peer sees you as. i.e. this is the receiver's external ip address (no port is included). -This may be both an IPv4 (4 bytes) or an IPv6 (16 bytes) -address. +This may be either an IPv4 (4 bytes) or an IPv6 +(16 bytes) address. reqq An integer, the number of outstanding request messages diff --git a/docs/manual.html b/docs/manual.html index d151db4d4..8bdde7ef9 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -35,7 +35,7 @@

  • set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()
  • set_max_uploads() set_max_connections()
  • num_uploads() num_connections()
  • -
  • set_max_half_open_connections()
  • +
  • set_max_half_open_connections() max_half_open_connections()
  • set_ip_filter()
  • status()
  • is_listening() listen_port() listen_on()
  • @@ -272,6 +272,7 @@ class session: public boost::noncopyable void set_max_uploads(int limit); void set_max_connections(int limit); void set_max_half_open_connections(int limit); + int max_half_open_connections() const; void set_peer_proxy(proxy_settings const& s); void set_web_seed_proxy(proxy_settings const& s); @@ -477,10 +478,11 @@ int num_connections() const; (including half-open ones) respectively.

    -

    set_max_half_open_connections()

    +

    set_max_half_open_connections() max_half_open_connections()

     void set_max_half_open_connections(int limit);
    +int max_half_open_connections() const;
     

    Sets the maximum number of half-open connections libtorrent will have when @@ -492,6 +494,8 @@ other network applications on that system. The default is to have no limit, and passing -1 as the limit, means to have no limit. When limiting the number of simultaneous connection attempts, peers will be put in a queue waiting for their turn to get connected.

    +

    max_half_open_connections() returns the set limit. This limit defaults +to 8 on windows.

    set_ip_filter()

    diff --git a/docs/manual.rst b/docs/manual.rst index 2d1f59214..9fb85a92b 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -102,6 +102,7 @@ The ``session`` class has the following synopsis:: void set_max_uploads(int limit); void set_max_connections(int limit); void set_max_half_open_connections(int limit); + int max_half_open_connections() const; void set_peer_proxy(proxy_settings const& s); void set_web_seed_proxy(proxy_settings const& s); @@ -323,12 +324,13 @@ Returns the number of currently unchoked peers and the number of connections (including half-open ones) respectively. -set_max_half_open_connections() -------------------------------- +set_max_half_open_connections() max_half_open_connections() +----------------------------------------------------------- :: void set_max_half_open_connections(int limit); + int max_half_open_connections() const; Sets the maximum number of half-open connections libtorrent will have when connecting to peers. A half-open connection is one where connect() has been @@ -340,6 +342,9 @@ and passing -1 as the limit, means to have no limit. When limiting the number of simultaneous connection attempts, peers will be put in a queue waiting for their turn to get connected. +``max_half_open_connections()`` returns the set limit. This limit defaults +to 8 on windows. + set_ip_filter() --------------- diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 74ca7c8f7..54a451892 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -275,6 +275,7 @@ namespace libtorrent int max_connections() const { return m_max_connections; } int max_uploads() const { return m_max_uploads; } + int max_half_open_connections() const { return m_half_open.limit(); } int num_uploads() const { return m_num_unchoked; } int num_connections() const diff --git a/include/libtorrent/session.hpp b/include/libtorrent/session.hpp index a7ccc8d57..2ce19349e 100755 --- a/include/libtorrent/session.hpp +++ b/include/libtorrent/session.hpp @@ -237,6 +237,7 @@ namespace libtorrent int upload_rate_limit() const; int download_rate_limit() const; + int max_half_open_connections() const; void set_upload_rate_limit(int bytes_per_second); void set_download_rate_limit(int bytes_per_second); diff --git a/src/session.cpp b/src/session.cpp index 818af3ada..dde39f4c7 100755 --- a/src/session.cpp +++ b/src/session.cpp @@ -349,6 +349,11 @@ namespace libtorrent m_impl->set_max_connections(limit); } + int session::max_half_open_connections() const + { + return m_impl->max_half_open_connections(); + } + void session::set_max_half_open_connections(int limit) { m_impl->set_max_half_open_connections(limit); diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f973690b3..c0c129e79 100755 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -532,6 +532,11 @@ namespace detail , m_next_connect_torrent(0) , m_checker_impl(*this) { +#ifdef WIN32 + // windows XP has a limit of 10 simultaneous connections + m_half_open.limit(8); +#endif + m_bandwidth_manager[peer_connection::download_channel] = &m_download_channel; m_bandwidth_manager[peer_connection::upload_channel] = &m_upload_channel; @@ -1254,29 +1259,7 @@ namespace detail assert(false); #endif }; // msvc 7.1 seems to require this -/* - void session_impl::connection_completed( - boost::intrusive_ptr const& p) try - { - mutex_t::scoped_lock l(m_mutex); - connection_map::iterator i = m_half_open.find(p->get_socket()); - m_connections.insert(std::make_pair(p->get_socket(), p)); - assert(i != m_half_open.end()); - if (i != m_half_open.end()) m_half_open.erase(i); - - if (m_abort) return; - - process_connection_queue(); - } - catch (std::exception& e) - { -#ifndef NDEBUG - std::cerr << e.what() << std::endl; - assert(false); -#endif - }; -*/ void session_impl::operator()() { eh_initializer();