diff --git a/include/ircd/m/fetch.h b/include/ircd/m/fetch.h index c8e167519..3b3973710 100644 --- a/include/ircd/m/fetch.h +++ b/include/ircd/m/fetch.h @@ -28,6 +28,7 @@ namespace ircd::m::fetch bool cancel(request &); bool start(const m::room::id &, const m::event::id &); bool prefetch(const m::room::id &, const m::event::id &); + size_t clear(); // Composed operations void auth_chain(const room &, const net::hostport &); diff --git a/modules/console.cc b/modules/console.cc index b5c5b4e32..de3f29f43 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -13388,6 +13388,18 @@ console_cmd__fetch(opt &out, const string_view &line) return true; } +bool +console_cmd__fetch__clear(opt &out, const string_view &line) +{ + const size_t cleared + { + m::fetch::clear() + }; + + out << "Cleared " << cleared << std::endl; + return true; +} + // // synchron // diff --git a/modules/m_fetch.cc b/modules/m_fetch.cc index 4920d8251..ba083fddd 100644 --- a/modules/m_fetch.cc +++ b/modules/m_fetch.cc @@ -553,6 +553,20 @@ catch(const std::exception &e) throw; } +size_t +IRCD_MODULE_EXPORT +ircd::m::fetch::clear() +{ + size_t ret{0}; + for_each([&ret](auto &request) + { + ret += cancel(request); + return true; + }); + + return ret; +} + bool IRCD_MODULE_EXPORT ircd::m::fetch::prefetch(const m::room::id &room_id,