0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02: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
{
"IRCd %s", reflect(new_runlevel)
};
ircd::log::fini();
for(const auto &handler : ircd::runlevel_changed::list)
(*handler)(new_runlevel);
});
}
if(new_runlevel != runlevel::HALT)
log::notice log::notice
{ {
"IRCd %s", reflect(new_runlevel) "IRCd %s", reflect(new_runlevel)
}; };
ircd::log::flush(); if(new_runlevel == runlevel::HALT)
ircd::log::fini();
else
ircd::log::flush();
for(const auto &handler : ircd::runlevel_changed::list)
(*handler)(new_runlevel);
}};
if(!ircd::runlevel_changed::list.empty())
ircd::post(call_users);
else
call_users();
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {