mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️:init::backfill: Fix interface; reenable for primary.
This commit is contained in:
parent
6122a7eb1f
commit
7ec7390211
5 changed files with 24 additions and 36 deletions
|
@ -14,10 +14,15 @@
|
|||
namespace ircd::m::init
|
||||
{
|
||||
struct modules;
|
||||
struct backfill;
|
||||
struct bootstrap;
|
||||
}
|
||||
|
||||
/// Internal use only; do not call
|
||||
namespace ircd::m::init::backfill
|
||||
{
|
||||
void init(), fini() noexcept;
|
||||
}
|
||||
|
||||
/// Internal use only; do not call
|
||||
struct ircd::m::init::modules
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ namespace ircd
|
|||
#include "error.h"
|
||||
#include "id.h"
|
||||
#include "self.h"
|
||||
#include "init.h"
|
||||
#include "event/event.h"
|
||||
#include "get.h"
|
||||
#include "query.h"
|
||||
|
|
|
@ -235,11 +235,17 @@ ircd::m::homeserver::homeserver(const struct opts *const &opts)
|
|||
m::keys::cache::set(key->verify_keys);
|
||||
|
||||
signon(*this);
|
||||
|
||||
if(primary == this)
|
||||
m::init::backfill::init();
|
||||
}
|
||||
|
||||
ircd::m::homeserver::~homeserver()
|
||||
noexcept
|
||||
{
|
||||
if(primary == this)
|
||||
m::init::backfill::fini();
|
||||
|
||||
signoff(*this);
|
||||
vm.reset();
|
||||
|
||||
|
|
|
@ -8,27 +8,17 @@
|
|||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
namespace ircd::m::init
|
||||
namespace ircd::m::init::backfill
|
||||
{
|
||||
struct backfill;
|
||||
}
|
||||
bool handle_event(const room::id &, const event::id &, const string_view &hint, const bool &ask_one);
|
||||
void handle_missing(const room::id &);
|
||||
void handle_room(const room::id &);
|
||||
void worker();
|
||||
|
||||
/// This should be a namespace but we're stuck in struct m::init for now, so
|
||||
/// this code should be portable for a future when m::init is unstructured.
|
||||
struct ircd::m::init::backfill
|
||||
{
|
||||
static bool handle_event(const room::id &, const event::id &, const string_view &hint, const bool &ask_one);
|
||||
static void handle_missing(const room::id &);
|
||||
static void handle_room(const room::id &);
|
||||
static void worker();
|
||||
static void fini();
|
||||
static void init();
|
||||
|
||||
static run::changed worker_terminator;
|
||||
static std::unique_ptr<context> worker_context;
|
||||
static conf::item<bool> enable;
|
||||
static conf::item<size_t> pool_size;
|
||||
static log::log log;
|
||||
extern std::unique_ptr<context> worker_context;
|
||||
extern conf::item<bool> enable;
|
||||
extern conf::item<size_t> pool_size;
|
||||
extern log::log log;
|
||||
};
|
||||
|
||||
decltype(ircd::m::init::backfill::log)
|
||||
|
@ -54,14 +44,6 @@ ircd::m::init::backfill::pool_size
|
|||
decltype(ircd::m::init::backfill::worker_context)
|
||||
ircd::m::init::backfill::worker_context;
|
||||
|
||||
decltype(ircd::m::init::backfill::worker_terminator)
|
||||
ircd::m::init::backfill::worker_terminator{[]
|
||||
(const auto &level)
|
||||
{
|
||||
if(level == run::level::QUIT && worker_context)
|
||||
worker_context->terminate();
|
||||
}};
|
||||
|
||||
void
|
||||
ircd::m::init::backfill::init()
|
||||
{
|
||||
|
@ -99,6 +81,7 @@ ircd::m::init::backfill::init()
|
|||
|
||||
void
|
||||
ircd::m::init::backfill::fini()
|
||||
noexcept
|
||||
{
|
||||
if(!worker_context)
|
||||
return;
|
||||
|
@ -115,17 +98,11 @@ void
|
|||
ircd::m::init::backfill::worker()
|
||||
try
|
||||
{
|
||||
// The common case is that we're in runlevel START when this context is
|
||||
// entered; we don't want to start this operation until we're in RUN.
|
||||
run::changed::dock.wait([]
|
||||
{
|
||||
return run::level != run::level::START;
|
||||
return run::level == run::level::RUN;
|
||||
});
|
||||
|
||||
// If some other level is observed here we shouldn't run this operation.
|
||||
if(run::level != run::level::RUN)
|
||||
return;
|
||||
|
||||
// Prepare to iterate all of the rooms this server is aware of which
|
||||
// contain at least one member from another server in any state, and
|
||||
// one member from our server in a joined state.
|
||||
|
|
|
@ -226,7 +226,6 @@ ircd::m::on_unload()
|
|||
noexcept try
|
||||
{
|
||||
//mods::imports.erase("m_listen"s);
|
||||
|
||||
if(m::sync::pool.size())
|
||||
m::sync::pool.join();
|
||||
|
||||
|
|
Loading…
Reference in a new issue