forked from premiere/premiere-libtorrent
added ability to give seeding torrents preference to active slots
This commit is contained in:
parent
065bd283cf
commit
6242ae051e
|
@ -48,6 +48,7 @@
|
||||||
* includes DHT traffic in the rate limiter
|
* includes DHT traffic in the rate limiter
|
||||||
* added support for bitcomet padding files
|
* added support for bitcomet padding files
|
||||||
* improved support for sparse files on windows
|
* improved support for sparse files on windows
|
||||||
|
* added ability to give seeding torrents preference to active slots
|
||||||
|
|
||||||
release 0.14.4
|
release 0.14.4
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ void bind_session_settings()
|
||||||
.def_readwrite("active_downloads", &session_settings::active_downloads)
|
.def_readwrite("active_downloads", &session_settings::active_downloads)
|
||||||
.def_readwrite("active_seeds", &session_settings::active_seeds)
|
.def_readwrite("active_seeds", &session_settings::active_seeds)
|
||||||
.def_readwrite("active_limit", &session_settings::active_limit)
|
.def_readwrite("active_limit", &session_settings::active_limit)
|
||||||
|
.def_readwrite("auto_manage_prefer_seeds", &session_settings::auto_manage_prefer_seeds)
|
||||||
.def_readwrite("dont_count_slow_torrents", &session_settings::dont_count_slow_torrents)
|
.def_readwrite("dont_count_slow_torrents", &session_settings::dont_count_slow_torrents)
|
||||||
.def_readwrite("auto_manage_interval", &session_settings::auto_manage_interval)
|
.def_readwrite("auto_manage_interval", &session_settings::auto_manage_interval)
|
||||||
.def_readwrite("share_ratio_limit", &session_settings::share_ratio_limit)
|
.def_readwrite("share_ratio_limit", &session_settings::share_ratio_limit)
|
||||||
|
|
|
@ -3406,6 +3406,7 @@ session_settings
|
||||||
int active_downloads;
|
int active_downloads;
|
||||||
int active_seeds;
|
int active_seeds;
|
||||||
int active_limit;
|
int active_limit;
|
||||||
|
bool auto_manage_prefer_seeds;
|
||||||
bool dont_count_slow_torrents;
|
bool dont_count_slow_torrents;
|
||||||
int auto_manage_interval;
|
int auto_manage_interval;
|
||||||
float share_ratio_limit;
|
float share_ratio_limit;
|
||||||
|
@ -3699,6 +3700,9 @@ torrents active. Torrents that are not auto managed are also counted against the
|
||||||
limits. If there are non-auto managed torrents that use up all the slots, no
|
limits. If there are non-auto managed torrents that use up all the slots, no
|
||||||
auto managed torrent will be activated.
|
auto managed torrent will be activated.
|
||||||
|
|
||||||
|
``auto_manage_prefer_seeds`` specifies if libtorrent should prefer giving seeds
|
||||||
|
active slots or downloading torrents. The default is ``false``.
|
||||||
|
|
||||||
if ``dont_count_slow_torrents`` is true, torrents without any payload transfers are
|
if ``dont_count_slow_torrents`` is true, torrents without any payload transfers are
|
||||||
not subject to the ``active_seeds`` and ``active_downloads`` limits. This is intended
|
not subject to the ``active_seeds`` and ``active_downloads`` limits. This is intended
|
||||||
to make it more likely to utilize all available bandwidth, and avoid having torrents
|
to make it more likely to utilize all available bandwidth, and avoid having torrents
|
||||||
|
|
|
@ -592,6 +592,8 @@ namespace libtorrent
|
||||||
|
|
||||||
void on_tick(error_code const& e);
|
void on_tick(error_code const& e);
|
||||||
|
|
||||||
|
int auto_manage_torrents(std::vector<torrent*>& list
|
||||||
|
, int hard_limit, int type_limit);
|
||||||
void recalculate_auto_managed_torrents();
|
void recalculate_auto_managed_torrents();
|
||||||
void recalculate_unchoke_slots(int congested_torrents
|
void recalculate_unchoke_slots(int congested_torrents
|
||||||
, int uncongested_torrents);
|
, int uncongested_torrents);
|
||||||
|
|
|
@ -136,6 +136,7 @@ namespace libtorrent
|
||||||
, active_downloads(8)
|
, active_downloads(8)
|
||||||
, active_seeds(5)
|
, active_seeds(5)
|
||||||
, active_limit(15)
|
, active_limit(15)
|
||||||
|
, auto_manage_prefer_seeds(false)
|
||||||
, dont_count_slow_torrents(true)
|
, dont_count_slow_torrents(true)
|
||||||
, auto_manage_interval(30)
|
, auto_manage_interval(30)
|
||||||
, share_ratio_limit(2.f)
|
, share_ratio_limit(2.f)
|
||||||
|
@ -439,6 +440,11 @@ namespace libtorrent
|
||||||
int active_seeds;
|
int active_seeds;
|
||||||
int active_limit;
|
int active_limit;
|
||||||
|
|
||||||
|
// prefer seeding torrents when determining which torrents to give
|
||||||
|
// active slots to, the default is false which gives preference to
|
||||||
|
// downloading torrents
|
||||||
|
bool auto_manage_prefer_seeds;
|
||||||
|
|
||||||
// if this is true, torrents that don't have any significant
|
// if this is true, torrents that don't have any significant
|
||||||
// transfers are not counted as active when determining which
|
// transfers are not counted as active when determining which
|
||||||
// auto managed torrents to pause and resume
|
// auto managed torrents to pause and resume
|
||||||
|
|
|
@ -1589,6 +1589,34 @@ namespace aux {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int session_impl::auto_manage_torrents(std::vector<torrent*>& list
|
||||||
|
, int hard_limit, int type_limit)
|
||||||
|
{
|
||||||
|
for (std::vector<torrent*>::iterator i = list.begin()
|
||||||
|
, end(list.end()); i != end; ++i)
|
||||||
|
{
|
||||||
|
torrent* t = *i;
|
||||||
|
if (!t->is_paused() && !is_active(t, settings())
|
||||||
|
&& hard_limit > 0)
|
||||||
|
{
|
||||||
|
--hard_limit;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type_limit > 0 && hard_limit > 0)
|
||||||
|
{
|
||||||
|
--hard_limit;
|
||||||
|
--type_limit;
|
||||||
|
if (t->is_paused()) t->resume();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!t->is_paused()) t->pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hard_limit;
|
||||||
|
}
|
||||||
|
|
||||||
void session_impl::recalculate_auto_managed_torrents()
|
void session_impl::recalculate_auto_managed_torrents()
|
||||||
{
|
{
|
||||||
// these vectors are filled with auto managed torrents
|
// these vectors are filled with auto managed torrents
|
||||||
|
@ -1654,51 +1682,17 @@ namespace aux {
|
||||||
> bind(&torrent::seed_rank, _2, boost::ref(m_settings)));
|
> bind(&torrent::seed_rank, _2, boost::ref(m_settings)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<torrent*>::iterator i = downloaders.begin()
|
if (settings().auto_manage_prefer_seeds)
|
||||||
, end(downloaders.end()); i != end; ++i)
|
|
||||||
{
|
{
|
||||||
torrent* t = *i;
|
hard_limit = auto_manage_torrents(seeds, hard_limit, num_seeds);
|
||||||
if (!t->is_paused() && !is_active(t, settings())
|
hard_limit = auto_manage_torrents(downloaders, hard_limit, num_downloaders);
|
||||||
&& hard_limit > 0)
|
|
||||||
{
|
|
||||||
--hard_limit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_downloaders > 0 && hard_limit > 0)
|
|
||||||
{
|
|
||||||
--hard_limit;
|
|
||||||
--num_downloaders;
|
|
||||||
if (t->is_paused()) t->resume();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!t->is_paused()) t->pause();
|
hard_limit = auto_manage_torrents(downloaders, hard_limit, num_downloaders);
|
||||||
}
|
hard_limit = auto_manage_torrents(seeds, hard_limit, num_seeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector<torrent*>::iterator i = seeds.begin()
|
|
||||||
, end(seeds.end()); i != end; ++i)
|
|
||||||
{
|
|
||||||
torrent* t = *i;
|
|
||||||
if (!t->is_paused() && !is_active(t, settings())
|
|
||||||
&& hard_limit > 0)
|
|
||||||
{
|
|
||||||
--hard_limit;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (num_seeds > 0 && hard_limit > 0)
|
|
||||||
{
|
|
||||||
--hard_limit;
|
|
||||||
--num_seeds;
|
|
||||||
if (t->is_paused()) t->resume();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!t->is_paused()) t->pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::recalculate_optimistic_unchoke_slot()
|
void session_impl::recalculate_optimistic_unchoke_slot()
|
||||||
|
|
Loading…
Reference in New Issue