0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 15:30:52 +01:00

modules/s_listen: Add runlevel::QUIT handler to stop listener harder.

This commit is contained in:
Jason Volk 2019-03-16 15:35:04 -07:00
parent 2eb9fff55f
commit cdb8308b02

View file

@ -18,6 +18,7 @@ static bool load_listener(const m::event &);
extern "C" bool unload_listener(const string_view &name); extern "C" bool unload_listener(const string_view &name);
extern "C" bool load_listener(const string_view &name); extern "C" bool load_listener(const string_view &name);
static void init_listeners(); static void init_listeners();
static void on_quit();
static void on_run(); static void on_run();
static void on_unload(); static void on_unload();
static void on_load(); static void on_load();
@ -29,10 +30,12 @@ IRCD_MODULE
}; };
const ircd::run::changed const ircd::run::changed
_on_run{[](const auto &level) _on_change{[](const auto &level)
{ {
if(level == run::level::RUN) if(level == run::level::RUN)
on_run(); on_run();
else if(level == run::level::QUIT)
on_quit();
}}; }};
/// Active listener state /// Active listener state
@ -85,6 +88,19 @@ on_run()
start(listener); start(listener);
} }
void
on_quit()
{
log::debug
{
"Disallowing %zu listeners from accepting connections...",
listeners.size()
};
for(auto &listener : listeners)
stop(listener);
}
void void
init_listeners() init_listeners()
{ {