mirror of
https://github.com/matrix-construct/construct
synced 2024-09-29 20:28:52 +02:00
modules/s_listen: Add runlevel::QUIT handler to stop listener harder.
This commit is contained in:
parent
2eb9fff55f
commit
cdb8308b02
1 changed files with 17 additions and 1 deletions
|
@ -18,6 +18,7 @@ static bool load_listener(const m::event &);
|
|||
extern "C" bool unload_listener(const string_view &name);
|
||||
extern "C" bool load_listener(const string_view &name);
|
||||
static void init_listeners();
|
||||
static void on_quit();
|
||||
static void on_run();
|
||||
static void on_unload();
|
||||
static void on_load();
|
||||
|
@ -29,10 +30,12 @@ IRCD_MODULE
|
|||
};
|
||||
|
||||
const ircd::run::changed
|
||||
_on_run{[](const auto &level)
|
||||
_on_change{[](const auto &level)
|
||||
{
|
||||
if(level == run::level::RUN)
|
||||
on_run();
|
||||
else if(level == run::level::QUIT)
|
||||
on_quit();
|
||||
}};
|
||||
|
||||
/// Active listener state
|
||||
|
@ -85,6 +88,19 @@ on_run()
|
|||
start(listener);
|
||||
}
|
||||
|
||||
void
|
||||
on_quit()
|
||||
{
|
||||
log::debug
|
||||
{
|
||||
"Disallowing %zu listeners from accepting connections...",
|
||||
listeners.size()
|
||||
};
|
||||
|
||||
for(auto &listener : listeners)
|
||||
stop(listener);
|
||||
}
|
||||
|
||||
void
|
||||
init_listeners()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue