made max half open connections default to 8 on windows and added query function for that limit on session.

This commit is contained in:
Arvid Norberg 2007-09-10 01:57:40 +00:00
parent 0d02fe0539
commit ee5ce50502
8 changed files with 45 additions and 44 deletions

View File

@ -215,12 +215,18 @@ with the libtorrent package.</li>
</ul> </ul>
</td> </td>
</tr> </tr>
<tr><td><tt class="docutils literal"><span class="pre">pe-support</span></tt></td> <tr><td><tt class="docutils literal"><span class="pre">openssl</span></tt></td>
<td><ul class="first last simple"> <td><ul class="first last simple">
<li><tt class="docutils literal"><span class="pre">on</span></tt> - turns on support for encrypted <li><tt class="docutils literal"><span class="pre">pe</span></tt> - turns on support for encrypted
connections. requires openssl (libcrypto)</li> connections. requires openssl (libcrypto)</li>
<li><tt class="docutils literal"><span class="pre">sha-1</span></tt> - openssl will be used instead of the
public domain SHA-1 implementation shipped with
libtorrent. <tt class="docutils literal"><span class="pre">libcrypto.a</span></tt> will be required for
linking. Encryption support is still turned off.</li>
<li><tt class="docutils literal"><span class="pre">off</span></tt> - turns off support for encrypted <li><tt class="docutils literal"><span class="pre">off</span></tt> - turns off support for encrypted
connections. openssl is not linked in.</li> connections. openssl is not linked in. The
shipped public domain SHA-1 implementation is
used.</li>
</ul> </ul>
</td> </td>
</tr> </tr>
@ -254,18 +260,6 @@ information.</li>
</ul> </ul>
</td> </td>
</tr> </tr>
<tr><td><tt class="docutils literal"><span class="pre">openssl</span></tt></td>
<td><ul class="first last simple">
<li><tt class="docutils literal"><span class="pre">on</span></tt> - openssl will be used instead of the
public domain SHA-1 implementation shipped with
libtorrent. <tt class="docutils literal"><span class="pre">crypto.lib</span></tt> or <tt class="docutils literal"><span class="pre">libcrypto.a</span></tt>
will be required for linking.</li>
<li><tt class="docutils literal"><span class="pre">off</span></tt> - the shipped SHA-1 implementation will
be used, and there will be no dependency on
openssl.</li>
</ul>
</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">character-set</span></tt></td> <tr><td><tt class="docutils literal"><span class="pre">character-set</span></tt></td>
<td><p class="first">This setting will only have an affect on windows. <td><p class="first">This setting will only have an affect on windows.
Other platforms are expected to support UTF-8.</p> Other platforms are expected to support UTF-8.</p>
@ -292,7 +286,8 @@ sure all build variants will actually compile), you can invoke this command:</p>
<pre class="literal-block"> <pre class="literal-block">
bjam debug release link=shared link=static logging=verbose logging=default \ 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 \ 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
</pre> </pre>
</div> </div>
</div> </div>
@ -504,6 +499,13 @@ torrents will be disabled.</td>
<td>This will enable verbose logging of the DHT <td>This will enable verbose logging of the DHT
protocol traffic.</td> protocol traffic.</td>
</tr> </tr>
<tr><td><tt class="docutils literal"><span class="pre">TORRENT_DISABLE_ENCRYPTION</span></tt></td>
<td>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.</td>
</tr>
</tbody> </tbody>
</table> </table>
<p>If you experience that libtorrent uses unreasonable amounts of cpu, it will <p>If you experience that libtorrent uses unreasonable amounts of cpu, it will

View File

@ -141,8 +141,8 @@ client than relying on the peer id encoding.</td>
<td>A string containing the compact representation of the ip <td>A string containing the compact representation of the ip
address this peer sees you as. i.e. this is the address this peer sees you as. i.e. this is the
receiver's external ip address (no port is included). receiver's external ip address (no port is included).
This may be both an IPv4 (4 bytes) or an IPv6 (16 bytes) This may be either an IPv4 (4 bytes) or an IPv6
address.</td> (16 bytes) address.</td>
</tr> </tr>
<tr><td>reqq</td> <tr><td>reqq</td>
<td>An integer, the number of outstanding request messages <td>An integer, the number of outstanding request messages

View File

@ -35,7 +35,7 @@
<li><a class="reference" href="#set-upload-rate-limit-set-download-rate-limit-upload-rate-limit-download-rate-limit" id="id24" name="id24">set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()</a></li> <li><a class="reference" href="#set-upload-rate-limit-set-download-rate-limit-upload-rate-limit-download-rate-limit" id="id24" name="id24">set_upload_rate_limit() set_download_rate_limit() upload_rate_limit() download_rate_limit()</a></li>
<li><a class="reference" href="#set-max-uploads-set-max-connections" id="id25" name="id25">set_max_uploads() set_max_connections()</a></li> <li><a class="reference" href="#set-max-uploads-set-max-connections" id="id25" name="id25">set_max_uploads() set_max_connections()</a></li>
<li><a class="reference" href="#num-uploads-num-connections" id="id26" name="id26">num_uploads() num_connections()</a></li> <li><a class="reference" href="#num-uploads-num-connections" id="id26" name="id26">num_uploads() num_connections()</a></li>
<li><a class="reference" href="#set-max-half-open-connections" id="id27" name="id27">set_max_half_open_connections()</a></li> <li><a class="reference" href="#set-max-half-open-connections-max-half-open-connections" id="id27" name="id27">set_max_half_open_connections() max_half_open_connections()</a></li>
<li><a class="reference" href="#set-ip-filter" id="id28" name="id28">set_ip_filter()</a></li> <li><a class="reference" href="#set-ip-filter" id="id28" name="id28">set_ip_filter()</a></li>
<li><a class="reference" href="#status" id="id29" name="id29">status()</a></li> <li><a class="reference" href="#status" id="id29" name="id29">status()</a></li>
<li><a class="reference" href="#is-listening-listen-port-listen-on" id="id30" name="id30">is_listening() listen_port() listen_on()</a></li> <li><a class="reference" href="#is-listening-listen-port-listen-on" id="id30" name="id30">is_listening() listen_port() listen_on()</a></li>
@ -272,6 +272,7 @@ class session: public boost::noncopyable
void set_max_uploads(int limit); void set_max_uploads(int limit);
void set_max_connections(int limit); void set_max_connections(int limit);
void set_max_half_open_connections(int limit); void set_max_half_open_connections(int limit);
int max_half_open_connections() const;
void set_peer_proxy(proxy_settings const&amp; s); void set_peer_proxy(proxy_settings const&amp; s);
void set_web_seed_proxy(proxy_settings const&amp; s); void set_web_seed_proxy(proxy_settings const&amp; s);
@ -477,10 +478,11 @@ int num_connections() const;
(including half-open ones) respectively.</p> (including half-open ones) respectively.</p>
</div> </div>
<div class="section"> <div class="section">
<h2><a id="set-max-half-open-connections" name="set-max-half-open-connections">set_max_half_open_connections()</a></h2> <h2><a id="set-max-half-open-connections-max-half-open-connections" name="set-max-half-open-connections-max-half-open-connections">set_max_half_open_connections() max_half_open_connections()</a></h2>
<blockquote> <blockquote>
<pre class="literal-block"> <pre class="literal-block">
void set_max_half_open_connections(int limit); void set_max_half_open_connections(int limit);
int max_half_open_connections() const;
</pre> </pre>
</blockquote> </blockquote>
<p>Sets the maximum number of half-open connections libtorrent will have when <p>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 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 of simultaneous connection attempts, peers will be put in a queue waiting for
their turn to get connected.</p> their turn to get connected.</p>
<p><tt class="docutils literal"><span class="pre">max_half_open_connections()</span></tt> returns the set limit. This limit defaults
to 8 on windows.</p>
</div> </div>
<div class="section"> <div class="section">
<h2><a id="set-ip-filter" name="set-ip-filter">set_ip_filter()</a></h2> <h2><a id="set-ip-filter" name="set-ip-filter">set_ip_filter()</a></h2>

View File

@ -102,6 +102,7 @@ The ``session`` class has the following synopsis::
void set_max_uploads(int limit); void set_max_uploads(int limit);
void set_max_connections(int limit); void set_max_connections(int limit);
void set_max_half_open_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_peer_proxy(proxy_settings const& s);
void set_web_seed_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. (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); 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 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 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 of simultaneous connection attempts, peers will be put in a queue waiting for
their turn to get connected. their turn to get connected.
``max_half_open_connections()`` returns the set limit. This limit defaults
to 8 on windows.
set_ip_filter() set_ip_filter()
--------------- ---------------

View File

@ -275,6 +275,7 @@ namespace libtorrent
int max_connections() const { return m_max_connections; } int max_connections() const { return m_max_connections; }
int max_uploads() const { return m_max_uploads; } 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_uploads() const { return m_num_unchoked; }
int num_connections() const int num_connections() const

View File

@ -237,6 +237,7 @@ namespace libtorrent
int upload_rate_limit() const; int upload_rate_limit() const;
int download_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_upload_rate_limit(int bytes_per_second);
void set_download_rate_limit(int bytes_per_second); void set_download_rate_limit(int bytes_per_second);

View File

@ -349,6 +349,11 @@ namespace libtorrent
m_impl->set_max_connections(limit); 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) void session::set_max_half_open_connections(int limit)
{ {
m_impl->set_max_half_open_connections(limit); m_impl->set_max_half_open_connections(limit);

View File

@ -532,6 +532,11 @@ namespace detail
, m_next_connect_torrent(0) , m_next_connect_torrent(0)
, m_checker_impl(*this) , 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::download_channel] = &m_download_channel;
m_bandwidth_manager[peer_connection::upload_channel] = &m_upload_channel; m_bandwidth_manager[peer_connection::upload_channel] = &m_upload_channel;
@ -1254,29 +1259,7 @@ namespace detail
assert(false); assert(false);
#endif #endif
}; // msvc 7.1 seems to require this }; // msvc 7.1 seems to require this
/*
void session_impl::connection_completed(
boost::intrusive_ptr<peer_connection> 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()() void session_impl::operator()()
{ {
eh_initializer(); eh_initializer();