0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

modules/s_fetch: Add conf item to toggle central control of unit.

This commit is contained in:
Jason Volk 2019-04-11 20:53:57 -07:00
parent 9a6c5f5fe4
commit aad53ba614
2 changed files with 17 additions and 3 deletions

View file

@ -16,6 +16,14 @@ IRCD_MODULE
"Event Fetch Unit", ircd::m::fetch::init, ircd::m::fetch::fini
};
decltype(ircd::m::fetch::enable)
ircd::m::fetch::enable
{
{ "name", "ircd.m.fetch.enable" },
{ "default", false },
{ "persist", false },
};
decltype(ircd::m::fetch::hook)
ircd::m::fetch::hook
{
@ -143,7 +151,12 @@ ircd::m::fetch::hook_handler(const event &event,
continue;
}
if((!opts.prev_fetch || !opts.prev_wait) && opts.prev_must_all_exist)
const bool can_fetch
{
opts.prev_fetch && bool(m::fetch::enable)
};
if((!can_fetch || !opts.prev_wait) && opts.prev_must_all_exist)
throw vm::error
{
vm::fault::EVENT, "Missing prev %s in %s in %s",
@ -152,10 +165,10 @@ ircd::m::fetch::hook_handler(const event &event,
json::get<"room_id"_>(*eval.event_)
};
if(opts.prev_fetch)
if(can_fetch)
start(prev_id, room_id);
if(opts.prev_fetch && opts.prev_wait)
if(can_fetch && opts.prev_wait)
dock.wait([&prev_id]
{
return !requests.count(prev_id);

View file

@ -24,6 +24,7 @@ namespace ircd::m::fetch
extern ctx::context eval_context;
extern ctx::context request_context;
extern hookfn<vm::eval &> hook;
extern conf::item<bool> enable;
template<class... args> static void start(const m::event::id &, const m::room::id &, args&&...);
static void eval_handle(const decltype(requests)::iterator &);