0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:vm::eval: Wait for duplicate evals instead or before any fault::EXISTS.

This commit is contained in:
Jason Volk 2020-03-13 11:42:49 -07:00
parent d3b91a5183
commit 05131c1bbe
2 changed files with 23 additions and 3 deletions

View file

@ -323,9 +323,20 @@ ircd::m::vm::eval::operator()(const vector_view<m::event> &events)
// When a fault::EXISTS would not actually be revealed to the user in
// any way we can elide a lot of grief by checking this here first and
// skipping the event. The query path will be adequately cached anyway.
if(~(opts->warnlog | opts->errorlog) & fault::EXISTS)
if(event.event_id && m::exists(event.event_id))
if(event.event_id && ~(opts->warnlog | opts->errorlog) & fault::EXISTS)
{
// If the event is already being evaluated, wait here until the other
// evaluation is finished. If the other was successful, the exists()
// check will skip this, otherwise we have to try again here because
// this evaluator might be using different options/credentials.
sequence::dock.wait([&event]
{
return eval::count(event.event_id) == 0;
});
if(m::exists(event.event_id))
continue;
}
const auto status
{

View file

@ -435,7 +435,16 @@ ircd::m::vm::execute_pdu(eval &eval,
fault::GENERAL, "Internal room event denied from external source."
};
if(unlikely(eval::count(event_id) > 1))
// Wait for any pending duplicate evals before proceeding.
assert(eval::count(event_id));
sequence::dock.wait([&event_id]
{
return eval::count(event_id) <= 1;
});
// This branch won't be taken anymore with the above condition added; but
// leaving the code for reference right now.
if((false) && unlikely(eval::count(event_id) > 1))
throw error
{
fault::EXISTS, "Event is already being evaluated."