mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd:Ⓜ️:acquire: Prevent duplicate fetch during submit.
This commit is contained in:
parent
5152cfb574
commit
a80c6f9c1c
1 changed files with 15 additions and 4 deletions
|
@ -13,7 +13,7 @@ namespace ircd::m::acquire
|
|||
struct result;
|
||||
using list = std::list<result>;
|
||||
|
||||
static void start(const opts &, list &);
|
||||
static bool start(const opts &, list &);
|
||||
static bool handle(const opts &, ctx::future<m::fetch::result> &);
|
||||
static bool handle(const opts &, list &);
|
||||
static void fetch_head(const opts &, list &);
|
||||
|
@ -229,14 +229,24 @@ void
|
|||
ircd::m::acquire::submit(const opts &opts,
|
||||
list &fetching)
|
||||
{
|
||||
start(opts, fetching);
|
||||
while(handle(opts, fetching));
|
||||
if(start(opts, fetching))
|
||||
while(handle(opts, fetching));
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
ircd::m::acquire::start(const opts &opts,
|
||||
list &fetching)
|
||||
{
|
||||
const auto match{[&opts]
|
||||
(const auto &result)
|
||||
{
|
||||
return opts.room.event_id == result.event_id;
|
||||
}};
|
||||
|
||||
// Check for duplicate.
|
||||
if(std::find_if(begin(fetching), end(fetching), match) != end(fetching))
|
||||
return false;
|
||||
|
||||
fetch::opts fopts;
|
||||
fopts.op = fetch::op::backfill;
|
||||
fopts.room_id = opts.room.room_id;
|
||||
|
@ -245,6 +255,7 @@ ircd::m::acquire::start(const opts &opts,
|
|||
fopts.hint = opts.hint;
|
||||
fopts.attempt_limit = opts.hint_only;
|
||||
fetching.emplace_back(fetch::start(fopts), opts.room.event_id);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue