summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
authorunknown <acurtis/antony@xiphis.org/ltamd64.xiphis.org>2007-05-04 16:44:07 -0700
committerunknown <acurtis/antony@xiphis.org/ltamd64.xiphis.org>2007-05-04 16:44:07 -0700
commitcd3ced79e9670f3dead8d4613d697f8c01db3d48 (patch)
tree7061f187342359f206ee25a91963f721fa2a1999 /sql/sql_plugin.cc
parent5dee5507a51d3b00f30f81f2afab18845f4d0dce (diff)
downloadmariadb-git-cd3ced79e9670f3dead8d4613d697f8c01db3d48.tar.gz
WL#2936
Move copying of global variables into thd.variables into plugin_thdvar_init(). plugin_thdvar_init() may be called multiple times when THD::change_user() is called. This fixes a plugin ref-count leak when running the test mysql_client_test sql/sql_class.cc: wl2936 Initialize thd.variables to zero in constructor. Move copying of global variables into thd.variables into plugin_thdvar_init() sql/sql_plugin.cc: wl2936 Move copying of global variables into thd.variables into plugin_thdvar_init(). plugin_thdvar_init() may be called multiple times when THD::change_user() is called. This fixes a plugin ref-count leak when running the test mysql_client_test
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index 590fee82027..66b6cb5d9eb 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -2303,14 +2303,26 @@ static byte *mysql_sys_var_ptr(void* a_thd, int offset)
void plugin_thdvar_init(THD *thd)
{
+ plugin_ref old_table_plugin= thd->variables.table_plugin;
+ DBUG_ENTER("plugin_thdvar_init");
+
+ thd->variables.table_plugin= NULL;
+ cleanup_variables(thd, &thd->variables);
+
+ thd->variables= global_system_variables;
+ thd->variables.table_plugin= NULL;
+
/* we are going to allocate these lazily */
thd->variables.dynamic_variables_version= 0;
thd->variables.dynamic_variables_size= 0;
thd->variables.dynamic_variables_ptr= 0;
- DBUG_ASSERT(!(thd->variables.table_plugin));
+ pthread_mutex_lock(&LOCK_plugin);
thd->variables.table_plugin=
- my_plugin_lock(NULL, &global_system_variables.table_plugin);
+ my_intern_plugin_lock(NULL, global_system_variables.table_plugin);
+ intern_plugin_unlock(NULL, old_table_plugin);
+ pthread_mutex_unlock(&LOCK_plugin);
+ DBUG_VOID_RETURN;
}