ircd::ios: Consolidate notification interface for now; add atexit related.

This commit is contained in:
Jason Volk 2022-06-29 13:53:37 -07:00
parent c664963e8d
commit 29b0523dfc
6 changed files with 80 additions and 43 deletions

View File

@ -250,7 +250,7 @@ void
construct::handle_cont()
try
{
ircd::cont();
ircd::ios::continuing();
}
catch(const std::exception &e)
{

View File

@ -34,9 +34,12 @@ namespace ircd::ios
bool available() noexcept;
const uint64_t &epoch() noexcept;
void forked_parent();
void forked_child();
void forking();
void forking(); // fork prepare
void forked_child(); // on fork child
void forked_parent(); // on fork parent
void continuing() noexcept; // on SIGCONT
void exiting() noexcept; // on atexit
void exiting_quick() noexcept; // on at_quick_exit
void init(asio::executor &&);
}

View File

@ -154,7 +154,6 @@ namespace ircd
seconds uptime();
// Control panel
void cont() noexcept;
bool quit() noexcept;
void init(boost::asio::executor &&, user_main);
}

View File

@ -79,7 +79,75 @@ ircd::ios::init(asio::executor &&user)
ios::main = *ios::primary;
}
[[using gnu: cold, visibility("hidden")]]
[[using gnu: cold]]
void
ircd::ios::exiting_quick()
noexcept
{
if(run::level == run::level::HALT)
return;
if(ircd::debugmode)
log::logf
{
log::star, log::level::DEBUG,
"IRCd notified of quick exit() in runlevel:%s ctx:%p",
reflect(run::level),
(const void *)ctx::current,
};
}
[[using gnu: cold]]
void
ircd::ios::exiting()
noexcept
{
if(run::level == run::level::HALT)
return;
if(ircd::debugmode)
log::logf
{
log::star, log::level::DEBUG,
"IRCd notified of exit() in runlevel:%s ctx:%p",
reflect(run::level),
(const void *)ctx::current,
};
}
[[using gnu: cold]]
void
ircd::ios::continuing()
noexcept
{
if(run::level == run::level::HALT)
return;
log::logf
{
log::star, log::level::DEBUG,
"IRCd notified of SIGCONT in runlevel:%s ctx:%p",
reflect(run::level),
(const void *)ctx::current,
};
switch(run::level)
{
case run::level::RUN:
break;
default:
return;
}
log::notice
{
log::star, "IRCd resuming service in runlevel %s.",
reflect(run::level),
};
}
[[using gnu: cold]]
void
ircd::ios::forking()
{
@ -90,7 +158,7 @@ ircd::ios::forking()
#endif
}
[[using gnu: cold, visibility("hidden")]]
[[using gnu: cold]]
void
ircd::ios::forked_child()
{
@ -101,7 +169,7 @@ ircd::ios::forked_child()
#endif
}
[[using gnu: cold, visibility("hidden")]]
[[using gnu: cold]]
void
ircd::ios::forked_parent()
{

View File

@ -293,39 +293,6 @@ noexcept
return false;
}
/// Notifies IRCd that execution is being resumed after a significant gap.
/// Basically this is connected to a SIGCONT handler and beneficial after
/// user stops, debugging and ACPI suspensions, etc. It is not required at
/// this time, but its connection is advised for best behavior.
void
ircd::cont()
noexcept
{
log::logf
{
log::star, log::level::DEBUG,
"IRCd cont requested from runlevel:%s ctx:%p main_context:%p",
reflect(run::level),
(const void *)ctx::current,
(const void *)main_context
};
switch(run::level)
{
case run::level::RUN:
break;
default:
return;
}
log::notice
{
log::star, "IRCd resuming service in runlevel %s.",
reflect(run::level),
};
}
/// Main context; Main program. Do not call this function directly.
///
/// This function manages the lifetime for all resources and subsystems

View File

@ -2796,7 +2796,7 @@ console_cmd__ctx__interrupt(opt &out, const string_view &line)
}};
size_t count(0);
for(size_t i(0); i < param.count() && cont; ++i)
for(size_t i(0); i < param.count(); ++i)
count += !ctx::for_each([&](auto &ctx)
{
if(id(ctx) == param.at<uint64_t>(i))
@ -2866,7 +2866,7 @@ console_cmd__ctx__term(opt &out, const string_view &line)
}};
size_t count(0);
for(size_t i(0); i < param.count() && cont; ++i)
for(size_t i(0); i < param.count(); ++i)
count += !ctx::for_each([&](auto &ctx)
{
if(id(ctx) == param.at<uint64_t>(i))