cleanup: plugin unload

* reduce code duplication
This commit is contained in:
Sergei Golubchik 2021-08-28 18:19:56 +02:00
parent 3050d5e80e
commit 06a8412b16

View file

@ -1263,23 +1263,16 @@ static void plugin_deinitialize(struct st_plugin_int *plugin, bool ref_check)
remove_status_vars(show_vars); remove_status_vars(show_vars);
} }
if (plugin_type_deinitialize[plugin->plugin->type]) plugin_type_init deinit= plugin_type_deinitialize[plugin->plugin->type];
{ if (!deinit)
if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin)) deinit= (plugin_type_init)(plugin->plugin->deinit);
if (deinit && deinit(plugin))
{ {
sql_print_error("Plugin '%s' of type %s failed deinitialization", sql_print_error("Plugin '%s' of type %s failed deinitialization",
plugin->name.str, plugin_type_names[plugin->plugin->type].str); plugin->name.str, plugin_type_names[plugin->plugin->type].str);
} }
}
else if (plugin->plugin->deinit)
{
DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str));
if (plugin->plugin->deinit(plugin))
{
DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.",
plugin->name.str));
}
}
plugin->state= PLUGIN_IS_UNINITIALIZED; plugin->state= PLUGIN_IS_UNINITIALIZED;
if (ref_check && plugin->ref_count) if (ref_check && plugin->ref_count)