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)
deinit= (plugin_type_init)(plugin->plugin->deinit);
if (deinit && deinit(plugin))
{ {
if ((*plugin_type_deinitialize[plugin->plugin->type])(plugin)) sql_print_error("Plugin '%s' of type %s failed deinitialization",
{ plugin->name.str, plugin_type_names[plugin->plugin->type].str);
sql_print_error("Plugin '%s' of type %s failed deinitialization",
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)
@ -1341,7 +1334,7 @@ static void reap_plugins(void)
list= reap; list= reap;
while ((plugin= *(--list))) while ((plugin= *(--list)))
plugin_deinitialize(plugin, true); plugin_deinitialize(plugin, true);
mysql_mutex_lock(&LOCK_plugin); mysql_mutex_lock(&LOCK_plugin);