mirror of
https://github.com/matrix-construct/construct
synced 2024-06-02 18:18:56 +02:00
ircd::server: Add opts::prio value; special case prio value in link selection.
This commit is contained in:
parent
c14f268559
commit
dcbbaf2579
|
@ -136,6 +136,15 @@ struct ircd::server::request::opts
|
|||
/// set this option to false.
|
||||
bool contiguous_content {true};
|
||||
|
||||
/// Priority indication is factored into the link selection algorithm for
|
||||
/// making this request to the peer. It is not the only factor, and the
|
||||
/// default is usually sufficient. Lower priority values are favored when
|
||||
/// two requests are compared. When the priority is set to the lowest
|
||||
/// possible value, a dedicated link may be opened to the peer even if the
|
||||
/// maximum number of links are already open; other limits may be exceeded;
|
||||
/// use that value with caution.
|
||||
int16_t priority {0};
|
||||
|
||||
/// Only applies when using dynamic content allocation with a chunked
|
||||
/// encoded response. This will hint the chunk vector. Ideally it can be
|
||||
/// set to the number of chunks expected in a response to avoid growth of
|
||||
|
|
|
@ -494,6 +494,9 @@ catch(const std::exception &e)
|
|||
ircd::server::link *
|
||||
ircd::server::peer::link_get(const request &request)
|
||||
{
|
||||
assert(request.opt);
|
||||
const auto &prio(request.opt->priority);
|
||||
|
||||
if(links.empty())
|
||||
return &link_add(1);
|
||||
|
||||
|
@ -559,6 +562,20 @@ ircd::server::peer::link_get(const request &request)
|
|||
best = &cand;
|
||||
}
|
||||
|
||||
// Even though the prio is set to the super special value we allow the
|
||||
// normal loop to first come up with a best link which already is open
|
||||
// rather than unconditionally opening a new connection.
|
||||
if(prio == std::numeric_limits<std::remove_reference<decltype(prio)>::type>::min())
|
||||
{
|
||||
if(!best)
|
||||
return &link_add(1);
|
||||
|
||||
if(best->tag_committed())
|
||||
return &link_add(1);
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
if(links_maxed)
|
||||
return best;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ try
|
|||
downloading_dock.notify_all();
|
||||
}};
|
||||
|
||||
if(exists(m::room{room_id}))
|
||||
if(exists(room_id))
|
||||
return room_id;
|
||||
|
||||
const unique_buffer<mutable_buffer> buf
|
||||
|
|
Loading…
Reference in a new issue