1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Bug#18903155: BACKPORT BUG-18008907 TO 5.5+ VERSIONS.

Backporting patch committed for bug 18008907 to 5.5
and 5.6.
This commit is contained in:
Praveenkumar Hulakund
2014-06-27 17:04:08 +05:30
parent 70eca99172
commit b2c2656b62
6 changed files with 227 additions and 6 deletions

View File

@@ -33,6 +33,7 @@
#include "sql_audit.h"
#include <mysql/plugin_auth.h>
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
#include "debug_sync.h"
#define REPORT_TO_LOG 1
#define REPORT_TO_USER 2
@@ -131,6 +132,12 @@ static int cur_plugin_info_interface_version[MYSQL_MAX_PLUGIN_TYPE_NUM]=
#include "sql_plugin_services.h"
/*
A mutex LOCK_plugin_delete must be acquired before calling plugin_del
function.
*/
mysql_mutex_t LOCK_plugin_delete;
/*
A mutex LOCK_plugin must be acquired before accessing the
following variables/structures.
@@ -949,6 +956,7 @@ static void plugin_del(struct st_plugin_int *plugin)
{
DBUG_ENTER("plugin_del(plugin)");
mysql_mutex_assert_owner(&LOCK_plugin);
mysql_mutex_assert_owner(&LOCK_plugin_delete);
/* Free allocated strings before deleting the plugin. */
mysql_rwlock_wrlock(&LOCK_system_variables_hash);
mysql_del_sys_var_chain(plugin->system_vars);
@@ -996,11 +1004,14 @@ static void reap_plugins(void)
while ((plugin= *(--list)))
plugin_deinitialize(plugin, true);
mysql_mutex_lock(&LOCK_plugin_delete);
mysql_mutex_lock(&LOCK_plugin);
while ((plugin= *(--reap)))
plugin_del(plugin);
mysql_mutex_unlock(&LOCK_plugin_delete);
my_afree(reap);
}
@@ -1205,10 +1216,12 @@ static inline void convert_underscore_to_dash(char *str, int len)
#ifdef HAVE_PSI_INTERFACE
static PSI_mutex_key key_LOCK_plugin;
static PSI_mutex_key key_LOCK_plugin_delete;
static PSI_mutex_info all_plugin_mutexes[]=
{
{ &key_LOCK_plugin, "LOCK_plugin", PSI_FLAG_GLOBAL}
{ &key_LOCK_plugin, "LOCK_plugin", PSI_FLAG_GLOBAL},
{ &key_LOCK_plugin_delete, "LOCK_plugin_delete", PSI_FLAG_GLOBAL}
};
static void init_plugin_psi_keys(void)
@@ -1259,6 +1272,7 @@ int plugin_init(int *argc, char **argv, int flags)
mysql_mutex_init(key_LOCK_plugin, &LOCK_plugin, MY_MUTEX_INIT_FAST);
mysql_mutex_init(key_LOCK_plugin_delete, &LOCK_plugin_delete, MY_MUTEX_INIT_FAST);
if (my_init_dynamic_array(&plugin_dl_array,
sizeof(struct st_plugin_dl *),16,16) ||
@@ -1401,8 +1415,10 @@ int plugin_init(int *argc, char **argv, int flags)
plugin_ptr->load_option == PLUGIN_FORCE_PLUS_PERMANENT)
reaped_mandatory_plugin= TRUE;
plugin_deinitialize(plugin_ptr, true);
mysql_mutex_lock(&LOCK_plugin_delete);
mysql_mutex_lock(&LOCK_plugin);
plugin_del(plugin_ptr);
mysql_mutex_unlock(&LOCK_plugin_delete);
}
mysql_mutex_unlock(&LOCK_plugin);
@@ -1692,10 +1708,11 @@ void plugin_shutdown(void)
}
/*
It's perfectly safe not to lock LOCK_plugin, as there're no
concurrent threads anymore. But some functions called from here
use mysql_mutex_assert_owner(), so we lock the mutex to satisfy it
It's perfectly safe not to lock LOCK_plugin, LOCK_plugin_delete, as
there're no concurrent threads anymore. But some functions called from
here use mysql_mutex_assert_owner(), so we lock the mutex to satisfy it
*/
mysql_mutex_lock(&LOCK_plugin_delete);
mysql_mutex_lock(&LOCK_plugin);
/*
@@ -1718,9 +1735,11 @@ void plugin_shutdown(void)
cleanup_variables(NULL, &global_system_variables);
cleanup_variables(NULL, &max_system_variables);
mysql_mutex_unlock(&LOCK_plugin);
mysql_mutex_unlock(&LOCK_plugin_delete);
initialized= 0;
mysql_mutex_destroy(&LOCK_plugin);
mysql_mutex_destroy(&LOCK_plugin_delete);
my_afree(plugins);
}
@@ -1795,6 +1814,7 @@ bool mysql_install_plugin(THD *thd, const LEX_STRING *name, const LEX_STRING *dl
mysql_audit_acquire_plugins(thd, MYSQL_AUDIT_GENERAL_CLASS);
mysql_mutex_lock(&LOCK_plugin);
DEBUG_SYNC(thd, "acquired_LOCK_plugin");
mysql_rwlock_wrlock(&LOCK_system_variables_hash);
if (my_load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, NULL))