0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-01 21:28:53 +02:00

ircd::mapi: Improve the stuck-module message by showing it immediately.

This commit is contained in:
Jason Volk 2016-09-24 19:45:37 -07:00
parent 6115671122
commit 1da6aa2b93
3 changed files with 20 additions and 11 deletions

View file

@ -110,14 +110,7 @@ inline
header::~header()
noexcept
{
if(ircd::main_exited)
{
// When central IRCd thinks this module is already unloaded when at this point,
// the DSO got stuck. This will not assert, but warn the developer to fix it.
const auto &name(meta["name"]);
log::warning("Module \"%s\" is stuck and failing to unload.", name.c_str());
log::warning("Module \"%s\" may result in undefined behavior if not fixed.", name.c_str());
}
mods::static_destruction = true;
}
const char *const

View file

@ -62,8 +62,6 @@ const std::string &desc(const mod &);
std::string location(const mod &);
std::string name(const mod &);
extern struct log::log log;
// Symbol handlers
struct type_handlers
{
@ -121,6 +119,9 @@ bool load(const std::string &name);
void autoload();
void unload();
extern struct log::log log;
extern bool static_destruction;
// Initialization and destruction singleton held by ircd::main()
struct init
{

View file

@ -199,6 +199,12 @@ catch(const std::exception &e)
throw;
}
// Allows module to communicate static destruction is taking place when mapi::header
// destructs. This allows us to gauge if the module *really* unloaded on command. DSO's
// are allowed to silently refuse to unload for any reason. We prefer developers to do
// things that don't trigger such behavior and allow a clean unload.
bool ircd::mods::static_destruction;
bool
ircd::mods::unload(const std::string name)
{
@ -215,8 +221,17 @@ ircd::mods::unload(const std::string name)
unload_symbol(mod, name, sym.type);
}
static_destruction = false;
mods.erase(it);
if(!static_destruction)
{
log.error("Module \"%s\" is stuck and failing to unload.", name.c_str());
log.warning("Module \"%s\" may result in undefined behavior if not fixed.", name.c_str());
} else {
log.info("Module '%s' unloaded", filename.c_str());
}
return true;
}