mirror of
https://github.com/matrix-construct/construct
synced 2025-02-18 09:40:12 +01:00
modules/s_fetch: Improve error handling on submit()/start(request).
This commit is contained in:
parent
d7cc387688
commit
e90d016d2e
2 changed files with 24 additions and 8 deletions
|
@ -768,18 +768,19 @@ catch(const std::exception &e)
|
|||
// fetch::request
|
||||
//
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::fetch::start(request &request)
|
||||
{
|
||||
m::v1::event::opts opts;
|
||||
opts.dynamic = true;
|
||||
opts.remote = request.origin?: select_random_origin(request);
|
||||
start(request, opts);
|
||||
return start(request, opts);
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::fetch::start(request &request,
|
||||
m::v1::event::opts &opts)
|
||||
try
|
||||
{
|
||||
assert(request.finished == 0);
|
||||
if(!request.started)
|
||||
|
@ -800,6 +801,21 @@ ircd::m::fetch::start(request &request,
|
|||
};
|
||||
|
||||
dock.notify_all();
|
||||
return true;
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
log::error
|
||||
{
|
||||
log, "Failed to start request for %s in %s to '%s' :%s",
|
||||
string_view{request.event_id},
|
||||
string_view{request.room_id},
|
||||
string_view{request.origin},
|
||||
e.what()
|
||||
};
|
||||
|
||||
request.origin = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
|
@ -836,7 +852,7 @@ ircd::m::fetch::select_random_origin(request &request)
|
|||
return true;
|
||||
}};
|
||||
|
||||
if(!origins.random(closure, proffer))
|
||||
if(!origins.random(closure, proffer) || !request.origin)
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"Cannot find any server to fetch %s in %s",
|
||||
|
|
|
@ -30,8 +30,8 @@ namespace ircd::m::fetch
|
|||
static string_view select_random_origin(request &);
|
||||
static void finish(request &);
|
||||
static void retry(request &);
|
||||
static void start(request &, m::v1::event::opts &);
|
||||
static void start(request &);
|
||||
static bool start(request &, m::v1::event::opts &);
|
||||
static bool start(request &);
|
||||
static bool handle(request &);
|
||||
|
||||
template<class... args> static void submit(const event::id &, const room::id &, const size_t &bufsz = 8_KiB, args&&...);
|
||||
|
@ -62,13 +62,13 @@ ircd::m::fetch::submit(const m::event::id &event_id,
|
|||
if(it == end(requests) || it->event_id != event_id) try
|
||||
{
|
||||
it = requests.emplace_hint(it, room_id, event_id, bufsz, std::forward<args>(a)...);
|
||||
start(const_cast<request &>(*it));
|
||||
while(!start(const_cast<request &>(*it)));
|
||||
}
|
||||
catch(const std::exception &e)
|
||||
{
|
||||
log::error
|
||||
{
|
||||
m::log, "Failed to start fetch for %s in %s :%s",
|
||||
m::log, "Failed to start any fetch for %s in %s :%s",
|
||||
string_view{event_id},
|
||||
string_view{room_id},
|
||||
e.what(),
|
||||
|
|
Loading…
Add table
Reference in a new issue