mirror of
https://github.com/transmission/transmission
synced 2025-01-03 05:25:52 +00:00
fix: low priority not working (#6079)
This commit is contained in:
parent
b9d1b33939
commit
5d64c860ea
6 changed files with 28 additions and 16 deletions
|
@ -83,7 +83,8 @@ void tr_bandwidth::notify_bandwidth_consumed_bytes(uint64_t const now, RateContr
|
|||
|
||||
// ---
|
||||
|
||||
tr_bandwidth::tr_bandwidth(tr_bandwidth* new_parent)
|
||||
tr_bandwidth::tr_bandwidth(tr_bandwidth* new_parent, bool is_group)
|
||||
: priority_(is_group ? TR_PRI_NONE : TR_PRI_NORMAL)
|
||||
{
|
||||
this->set_parent(new_parent);
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ void tr_bandwidth::allocate_bandwidth(
|
|||
uint64_t period_msec,
|
||||
std::vector<std::shared_ptr<tr_peerIo>>& peer_pool)
|
||||
{
|
||||
auto const priority = std::max(parent_priority, this->priority_);
|
||||
auto const priority = std::min(parent_priority, this->priority_);
|
||||
|
||||
// set the available bandwidth
|
||||
for (auto const dir : { TR_UP, TR_DOWN })
|
||||
|
@ -161,6 +162,7 @@ void tr_bandwidth::allocate_bandwidth(
|
|||
// add this bandwidth's peer, if any, to the peer pool
|
||||
if (auto shared = this->peer_.lock(); shared)
|
||||
{
|
||||
TR_ASSERT(tr_isPriority(priority));
|
||||
shared->set_priority(priority);
|
||||
peer_pool.push_back(std::move(shared));
|
||||
}
|
||||
|
@ -223,7 +225,7 @@ void tr_bandwidth::allocate(uint64_t period_msec)
|
|||
// allocateBandwidth () is a helper function with two purposes:
|
||||
// 1. allocate bandwidth to b and its subtree
|
||||
// 2. accumulate an array of all the peerIos from b and its subtree.
|
||||
this->allocate_bandwidth(TR_PRI_LOW, period_msec, refs);
|
||||
this->allocate_bandwidth(TR_PRI_NONE, period_msec, refs);
|
||||
|
||||
for (auto const& io : refs)
|
||||
{
|
||||
|
@ -239,8 +241,13 @@ void tr_bandwidth::allocate(uint64_t period_msec)
|
|||
normal.push_back(io.get());
|
||||
[[fallthrough]];
|
||||
|
||||
default:
|
||||
case TR_PRI_LOW:
|
||||
low.push_back(io.get());
|
||||
break;
|
||||
|
||||
default:
|
||||
TR_ASSERT_MSG(false, "invalid priority");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,10 @@ private:
|
|||
static constexpr size_t HistorySize = HistoryMSec / GranularityMSec;
|
||||
|
||||
public:
|
||||
explicit tr_bandwidth(tr_bandwidth* new_parent);
|
||||
explicit tr_bandwidth(tr_bandwidth* new_parent, bool is_group = false);
|
||||
|
||||
tr_bandwidth()
|
||||
: tr_bandwidth{ nullptr }
|
||||
explicit tr_bandwidth(bool is_group = false)
|
||||
: tr_bandwidth{ nullptr, is_group }
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -274,7 +274,12 @@ private:
|
|||
std::vector<tr_bandwidth*> children_;
|
||||
tr_bandwidth* parent_ = nullptr;
|
||||
std::weak_ptr<tr_peerIo> peer_;
|
||||
tr_priority_t priority_ = 0;
|
||||
tr_priority_t priority_;
|
||||
};
|
||||
|
||||
/* @} */
|
||||
|
||||
constexpr bool tr_isPriority(tr_priority_t p)
|
||||
{
|
||||
return p == TR_PRI_LOW || p == TR_PRI_NORMAL || p == TR_PRI_HIGH;
|
||||
}
|
||||
|
|
|
@ -2363,6 +2363,10 @@ struct peer_candidate
|
|||
case TR_PRI_LOW:
|
||||
i = 2;
|
||||
break;
|
||||
|
||||
default:
|
||||
TR_ASSERT_MSG(false, "invalid priority");
|
||||
break;
|
||||
}
|
||||
|
||||
score = addValToKey(score, 4U, i);
|
||||
|
|
|
@ -1647,7 +1647,7 @@ tr_bandwidth& tr_session::getBandwidthGroup(std::string_view name)
|
|||
}
|
||||
}
|
||||
|
||||
auto& [group_name, group] = groups.emplace_back(name, std::make_unique<tr_bandwidth>(new tr_bandwidth(&top_bandwidth_)));
|
||||
auto& [group_name, group] = groups.emplace_back(name, std::make_unique<tr_bandwidth>(&top_bandwidth_, true));
|
||||
return *group;
|
||||
}
|
||||
|
||||
|
|
|
@ -1125,7 +1125,7 @@ public:
|
|||
std::unique_ptr<tr_udp_core> udp_core_;
|
||||
|
||||
// monitors the "global pool" speeds
|
||||
tr_bandwidth top_bandwidth_;
|
||||
tr_bandwidth top_bandwidth_{ true };
|
||||
|
||||
private:
|
||||
// depends-on: top_bandwidth_
|
||||
|
@ -1203,8 +1203,3 @@ private:
|
|||
public:
|
||||
std::unique_ptr<libtransmission::Timer> utp_timer;
|
||||
};
|
||||
|
||||
constexpr bool tr_isPriority(tr_priority_t p)
|
||||
{
|
||||
return p == TR_PRI_LOW || p == TR_PRI_NORMAL || p == TR_PRI_HIGH;
|
||||
}
|
||||
|
|
|
@ -1024,7 +1024,8 @@ enum : tr_priority_t
|
|||
{
|
||||
TR_PRI_LOW = -1,
|
||||
TR_PRI_NORMAL = 0, /* since Normal is 0, memset initializes nicely */
|
||||
TR_PRI_HIGH = 1
|
||||
TR_PRI_HIGH = 1,
|
||||
TR_PRI_NONE
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue