0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 22:41:12 +01:00

ircd: Cleanup runlevel change routine.

This commit is contained in:
Jason Volk 2018-08-11 00:39:06 -07:00
parent f51fde206a
commit a8a2015ec9

View file

@ -284,32 +284,31 @@ try
ircd::_runlevel = new_runlevel; ircd::_runlevel = new_runlevel;
ircd::runlevel_changed::dock.notify_all(); ircd::runlevel_changed::dock.notify_all();
// This function will notify the user of the change to IRCd. The // This function will notify the user of the change to IRCd. When there
// notification is posted to the io_context ensuring THERE IS NO // are listeners, function is posted to the io_context ensuring THERE IS
// CONTINUATION ON THIS STACK by the user. // NO CONTINUATION ON THIS STACK by the user.
if(!ircd::runlevel_changed::list.empty()) const auto call_users{[new_runlevel]
{ {
ircd::post([new_runlevel] assert(new_runlevel == ircd::_runlevel);
{
if(new_runlevel == runlevel::HALT)
log::notice log::notice
{ {
"IRCd %s", reflect(new_runlevel) "IRCd %s", reflect(new_runlevel)
}; };
if(new_runlevel == runlevel::HALT)
ircd::log::fini(); ircd::log::fini();
else
ircd::log::flush();
for(const auto &handler : ircd::runlevel_changed::list) for(const auto &handler : ircd::runlevel_changed::list)
(*handler)(new_runlevel); (*handler)(new_runlevel);
}); }};
}
if(new_runlevel != runlevel::HALT) if(!ircd::runlevel_changed::list.empty())
log::notice ircd::post(call_users);
{ else
"IRCd %s", reflect(new_runlevel) call_users();
};
ircd::log::flush();
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {