mirror of
https://github.com/matrix-construct/construct
synced 2024-05-29 00:03:45 +02:00
ircd::mods: Disable interruption on unload(); guard unloading list; noexcept.
This commit is contained in:
parent
c0892e79f4
commit
28f0195b59
13
ircd/mods.cc
13
ircd/mods.cc
|
@ -71,6 +71,7 @@ ircd::mapi::static_destruction;
|
|||
|
||||
bool
|
||||
ircd::mods::unload(mod &mod)
|
||||
noexcept
|
||||
{
|
||||
if(!mod.handle.is_loaded())
|
||||
return false;
|
||||
|
@ -78,9 +79,7 @@ ircd::mods::unload(mod &mod)
|
|||
if(mods::unloading(mod.name()))
|
||||
return false;
|
||||
|
||||
// Mark this module in the unloading state.
|
||||
mod.unloading.emplace_front(&mod);
|
||||
|
||||
const ctx::uninterruptible::nothrow ui;
|
||||
log::debug
|
||||
{
|
||||
log, "Attempting unload module '%s' @ `%s'",
|
||||
|
@ -88,6 +87,13 @@ ircd::mods::unload(mod &mod)
|
|||
mod.location()
|
||||
};
|
||||
|
||||
// Mark this module in the unloading state.
|
||||
mod.unloading.emplace_front(&mod);
|
||||
const unwind unloading_remove{[&mod]
|
||||
{
|
||||
mod.unloading.remove(&mod);
|
||||
}};
|
||||
|
||||
// Save the children! dlclose() does not like to be called recursively during static
|
||||
// destruction of a module. The mod ctor recorded all of the modules loaded while this
|
||||
// module was loading so we can reverse the record and unload them here.
|
||||
|
@ -110,7 +116,6 @@ ircd::mods::unload(mod &mod)
|
|||
mod.handle.unload();
|
||||
|
||||
mod.loaded.erase(mod.name());
|
||||
mod.unloading.remove(&mod);
|
||||
log::debug
|
||||
{
|
||||
log, "Static unload for '%s' complete=%b loaded:%zu unloading:%zu children:%zu",
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace ircd::mods
|
|||
|
||||
void handle_ebadf(const string_view &what);
|
||||
void handle_stuck(mod &);
|
||||
bool unload(mod &);
|
||||
bool unload(mod &) noexcept;
|
||||
|
||||
extern const std::string prefix;
|
||||
extern const std::string suffix;
|
||||
|
|
Loading…
Reference in a new issue