0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-29 00:03:45 +02:00

ircd:Ⓜ️:fetch: Add an attempt_limit option to interface; minor cleanup.

This commit is contained in:
Jason Volk 2019-09-16 12:21:20 -07:00
parent 2d1911a2b1
commit a9b86c5594
2 changed files with 10 additions and 3 deletions

View file

@ -92,6 +92,11 @@ struct ircd::m::fetch::opts
/// is not known to us, it would be best to set this.
string_view hint;
/// Limit the number of servers to be contacted for this operation. Zero
/// is automatic / unlimited. Note that setting this value to 1 in
/// conjunction with a hint is analogous to just making an m::fed request.
size_t attempt_limit {0};
//
// special options
//

View file

@ -403,7 +403,8 @@ catch(const std::exception &e)
//
bool
ircd::m::fetch::start(request &request) try
ircd::m::fetch::start(request &request)
try
{
assert(!request.finished);
if(!request.started && !request.origin)
@ -415,12 +416,13 @@ ircd::m::fetch::start(request &request) try
if(!request.origin)
select_random_origin(request);
while(request.origin)
for(; request.origin; select_random_origin(request))
{
if(start(request, request.origin))
return true;
select_random_origin(request);
if(request.attempted.size() > request.opts.attempt_limit - 1UL)
break;
}
assert(!request.finished);