added accessor to query for the max number of connections

This commit is contained in:
Arvid Norberg 2008-11-08 07:40:55 +00:00
parent 71fb640699
commit 4e9124019b
7 changed files with 28 additions and 5 deletions

View File

@ -116,6 +116,7 @@ The ``session`` class has the following synopsis::
int download_rate_limit() const;
void set_max_uploads(int limit);
void set_max_connections(int limit);
int max_connections() const;
void set_max_half_open_connections(int limit);
int max_half_open_connections() const;
@ -406,13 +407,14 @@ of upload rate.
set limits.
set_max_uploads() set_max_connections()
---------------------------------------
set_max_uploads() set_max_connections() max_connections()
---------------------------------------------------------
::
void set_max_uploads(int limit);
void set_max_connections(int limit);
int max_connections() const;
These functions will set a global limit on the number of unchoked peers (uploads)
and the number of connections opened. The number of connections is set to a hard
@ -420,6 +422,8 @@ minimum of at least two connections per torrent, so if you set a too low
connections limit, and open too many torrents, the limit will not be met. The
number of uploads is at least one per torrent.
``max_connections()`` returns the current setting.
num_uploads() num_connections()
-------------------------------
@ -1616,6 +1620,7 @@ Its declaration looks like this::
void set_ratio(float ratio) const;
void set_max_uploads(int max_uploads) const;
void set_max_connections(int max_connections) const;
int max_connections() const;
void set_upload_limit(int limit) const;
int upload_limit() const;
void set_download_limit(int limit) const;
@ -2123,13 +2128,14 @@ info_hash()
``info_hash()`` returns the info-hash for the torrent.
set_max_uploads() set_max_connections()
---------------------------------------
set_max_uploads() set_max_connections() max_connections()
---------------------------------------------------------
::
void set_max_uploads(int max_uploads) const;
void set_max_connections(int max_connections) const;
int max_connections() const;
``set_max_uploads()`` sets the maximum number of peers that's unchoked at the same time on this
torrent. If you set this to -1, there will be no limit.
@ -2139,6 +2145,8 @@ connections are used up, incoming connections may be refused or poor connections
This must be at least 2. The default is unlimited number of connections. If -1 is given to the
function, it means unlimited.
``max_connections()`` returns the current setting.
save_resume_data()
------------------

View File

@ -326,6 +326,8 @@ namespace libtorrent
void set_max_connections(int limit);
void set_max_half_open_connections(int limit);
int max_connections() const;
std::auto_ptr<alert> pop_alert();
#ifndef TORRENT_NO_DEPRECATE
void set_severity_level(alert::severity_t s) TORRENT_DEPRECATED;

View File

@ -463,6 +463,7 @@ namespace libtorrent
// -1 means unlimited connections
void set_max_connections(int max_connections) const;
int max_connections() const;
void set_tracker_login(std::string const& name
, std::string const& password) const;

View File

@ -122,7 +122,7 @@ namespace libtorrent
while (!m_queue.empty())
{
// we don't want to call the timeout callback while we're locked
// since that is a recepie for dead-locks
// since that is a recipie for dead-locks
entry e = m_queue.front();
m_queue.pop_front();
if (e.connecting) --m_num_connecting;

View File

@ -714,6 +714,7 @@ namespace libtorrent
void disk_io_thread::free_buffer(char* buf)
{
TORRENT_ASSERT(buf);
mutex_t::scoped_lock l(m_pool_mutex);
#ifdef TORRENT_STATS
--m_allocations;

View File

@ -501,6 +501,11 @@ namespace libtorrent
m_impl->set_max_uploads(limit);
}
int session::max_connections() const
{
return m_impl->max_connections();
}
void session::set_max_connections(int limit)
{
m_impl->set_max_connections(limit);

View File

@ -161,6 +161,12 @@ namespace libtorrent
TORRENT_FORWARD(use_interface(net_interface));
}
int torrent_handle::max_connections() const
{
INVARIANT_CHECK;
TORRENT_FORWARD_RETURN(max_connections(), 0);
}
void torrent_handle::set_max_connections(int max_connections) const
{
INVARIANT_CHECK;