1 parent
9a54f15e7e
commit
f94366104e
7 files changed
+100
-13
No files matched your search
+23
-2
@@ -25,6 +25,7 @@ namespace Void::Plugin
|
||||
destroy_fn destroy{nullptr};
|
||||
transfer_fn transfer{nullptr};
|
||||
configure_fn configure{nullptr};
|
||||
ready_fn ready{nullptr};
|
||||
state_version_fn state_version{nullptr};
|
||||
serialize_fn serialize{nullptr};
|
||||
free_string_fn free_string{nullptr};
|
||||
@@ -121,6 +122,8 @@ namespace Void::Plugin
|
||||
reinterpret_cast<transfer_fn>(dlsym(h, kTransferSymbol));
|
||||
inst->configure =
|
||||
reinterpret_cast<configure_fn>(dlsym(h, kConfigureSymbol));
|
||||
inst->ready =
|
||||
reinterpret_cast<ready_fn>(dlsym(h, kReadySymbol));
|
||||
inst->state_version = reinterpret_cast<state_version_fn>(
|
||||
dlsym(h, kStateVersionSymbol));
|
||||
inst->serialize =
|
||||
@@ -243,7 +246,15 @@ namespace Void::Plugin
|
||||
const std::string config = m_options.config_provider(name);
|
||||
(*inst)->configure((*inst)->plugin, config.c_str());
|
||||
}
|
||||
(*inst)->plugin->on_load();
|
||||
try {
|
||||
(*inst)->plugin->on_load();
|
||||
} catch (...) {
|
||||
return std::unexpected{LoadError::ActivationFailed};
|
||||
}
|
||||
if ((*inst)->ready != nullptr &&
|
||||
(*inst)->ready((*inst)->plugin) != 0) {
|
||||
return std::unexpected{LoadError::ActivationFailed};
|
||||
}
|
||||
|
||||
std::lock_guard lock(m_mutex);
|
||||
auto entry = std::make_unique<Entry>();
|
||||
@@ -372,7 +383,17 @@ namespace Void::Plugin
|
||||
}
|
||||
}
|
||||
|
||||
(*next)->plugin->on_load();
|
||||
try {
|
||||
(*next)->plugin->on_load();
|
||||
} catch (...) {
|
||||
return std::unexpected{LoadError::ActivationFailed};
|
||||
}
|
||||
if ((*next)->ready != nullptr &&
|
||||
(*next)->ready((*next)->plugin) != 0) {
|
||||
Void::Log::warn("Plugin.Manager",
|
||||
"reload '{}' aborted: activation failed", name);
|
||||
return std::unexpected{LoadError::ActivationFailed};
|
||||
}
|
||||
// Atomic swap. The old instance keeps living while any acquired
|
||||
// handle still pins it; it is destroyed when the last one drops.
|
||||
entry.current.store(std::move(*next), std::memory_order_release);
|
||||
|
||||
Reference in new issue
Block a user