0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd:Ⓜ️:fetch: Pass boolean values down the stack for start/prefetch.

This commit is contained in:
Jason Volk 2019-04-18 01:20:49 -07:00
parent 477090ff52
commit 871fb748eb
4 changed files with 24 additions and 12 deletions

View file

@ -25,8 +25,8 @@ namespace ircd::m::fetch
// Control panel
bool cancel(request &);
void start(const m::room::id &, const m::event::id &);
bool prefetch(const m::room::id &, const m::event::id &);
bool start(const m::room::id &, const m::event::id & = {});
bool prefetch(const m::room::id &, const m::event::id & = {});
// Composed operations
void auth_chain(const room &, const net::hostport &);

View file

@ -536,11 +536,11 @@ ircd::m::fetch::prefetch(const m::room::id &room_id,
return call(room_id, event_id);
}
void
bool
ircd::m::fetch::start(const m::room::id &room_id,
const m::event::id &event_id)
{
using prototype = void (const m::room::id &, const m::event::id &);
using prototype = bool (const m::room::id &, const m::event::id &);
static mods::import<prototype> call
{

View file

@ -432,8 +432,19 @@ try
string_view{result.origin},
};
size_t count(0);
for(const json::string &event_id : ids)
fetch::prefetch(room.room_id, event_id);
count += fetch::prefetch(room.room_id, event_id);
if(count)
log::debug
{
log, "Prefetched %zu of %zu state_ids for %s from '%s'",
count,
ids.size(),
string_view{room.room_id},
string_view{result.origin},
};
}
catch(const std::exception &e)
{
@ -546,11 +557,10 @@ ircd::m::fetch::prefetch(const m::room::id &room_id,
if(m::exists(event_id))
return false;
start(room_id, event_id);
return true;
return start(room_id, event_id);
}
void
bool
IRCD_MODULE_EXPORT
ircd::m::fetch::start(const m::room::id &room_id,
const m::event::id &event_id)
@ -570,7 +580,7 @@ ircd::m::fetch::start(const m::room::id &room_id,
reflect(run::level)
};
submit(event_id, room_id);
return submit(event_id, room_id);
}
bool

View file

@ -36,7 +36,7 @@ namespace ircd::m::fetch
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&&...);
template<class... args> static bool submit(const event::id &, const room::id &, const size_t &bufsz = 8_KiB, args&&...);
static void eval_handle(const decltype(requests)::iterator &);
static void eval_handle();
static void eval_worker();
@ -50,7 +50,7 @@ namespace ircd::m::fetch
}
template<class... args>
void
bool
ircd::m::fetch::submit(const m::event::id &event_id,
const m::room::id &room_id,
const size_t &bufsz,
@ -65,6 +65,7 @@ ircd::m::fetch::submit(const m::event::id &event_id,
{
it = requests.emplace_hint(it, room_id, event_id, bufsz, std::forward<args>(a)...);
while(!start(const_cast<request &>(*it)));
return true;
}
catch(const std::exception &e)
{
@ -77,8 +78,9 @@ ircd::m::fetch::submit(const m::event::id &event_id,
};
requests.erase(it);
return;
return false;
};
assert(it->room_id == room_id);
return false;
}