0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-03 04:02:47 +01:00

ircd:Ⓜ️:homeserver: Consolidate legacy shutdown procedure on primary dtor for now.

This commit is contained in:
Jason Volk 2020-02-27 15:46:05 -08:00
parent 1c305257af
commit e27dd573ad
2 changed files with 34 additions and 31 deletions

View file

@ -161,6 +161,15 @@ ircd::m::origin(const homeserver &homeserver)
// homeserver::homeserver // homeserver::homeserver
// //
/// --- tmp ---
namespace ircd::m
{
std::unique_ptr<fetch::init> _fetch;
}
/// --- /tmp ---
decltype(ircd::m::homeserver::primary) decltype(ircd::m::homeserver::primary)
ircd::m::homeserver::primary; ircd::m::homeserver::primary;
@ -172,6 +181,11 @@ try
assert(opts); assert(opts);
rfc3986::valid_host(opts->origin); rfc3986::valid_host(opts->origin);
rfc3986::valid_host(opts->server_name); rfc3986::valid_host(opts->server_name);
//TODO: XXX
if(!_fetch)
_fetch = std::make_unique<fetch::init>();
return new homeserver return new homeserver
{ {
opts opts
@ -262,14 +276,30 @@ ircd::m::homeserver::~homeserver()
noexcept noexcept
{ {
if(primary == this) if(primary == this)
m::init::backfill::fini(); {
//TODO: remove this for non-interfering shutdown
signoff(*this); server::init::interrupt();
vm.reset(); client::terminate_all();
server::init::close();
client::close_all();
client::wait_all();
server::init::wait();
}
if(primary == this)
{
m::init::backfill::fini();
m::sync::pool.join();
}
signoff(*this);
if(primary == this) if(primary == this)
mods::imports.erase("net_dns_cache"s); mods::imports.erase("net_dns_cache"s);
vm.reset();
if(primary == this)
_fetch.reset(nullptr);
while(!modules.empty()) while(!modules.empty())
modules.pop_back(); modules.pop_back();
} }

View file

@ -163,27 +163,11 @@ ircd::m::matrix::module_names_optional
// init // init
// //
/// --- tmp ---
namespace ircd::m::init
{
struct modules;
}
namespace ircd::m
{
std::unique_ptr<fetch::init> _fetch;
//std::unique_ptr<init::modules> _modules;
}
/// --- /tmp ---
void void
ircd::m::on_load() ircd::m::on_load()
try try
{ {
assert(ircd::run::level == run::level::IDLE); assert(ircd::run::level == run::level::IDLE);
_fetch = std::make_unique<fetch::init>();
} }
catch(const m::error &e) catch(const m::error &e)
{ {
@ -221,18 +205,7 @@ void
ircd::m::on_unload() ircd::m::on_unload()
noexcept try noexcept try
{ {
if(m::sync::pool.size())
m::sync::pool.join();
_fetch.reset(nullptr);
//TODO: remove this for non-interfering shutdown
//server::interrupt_all();
//client::terminate_all();
//client::close_all();
//server::close_all();
//server::wait_all();
//client::wait_all();
} }
catch(const m::error &e) catch(const m::error &e)
{ {