Commit 6156581e authored by Staale Smedseng's avatar Staale Smedseng

Bug#51591 deadlock in the plugins+status+variables

      
Potential deadlock situation involving LOCK_plugin,
LOCK_global_system_variables and LOCK_status.
      
This patch backports the fix from next-mr, unlocking
LOCK_plugin before calling plugin->init() and
add_status_vars().
parent 0d242648
......@@ -1006,9 +1006,14 @@ void plugin_unlock_list(THD *thd, plugin_ref *list, uint count)
static int plugin_initialize(struct st_plugin_int *plugin)
{
int ret= 1;
DBUG_ENTER("plugin_initialize");
safe_mutex_assert_owner(&LOCK_plugin);
uint state= plugin->state;
DBUG_ASSERT(state == PLUGIN_IS_UNINITIALIZED);
pthread_mutex_unlock(&LOCK_plugin);
if (plugin_type_initialize[plugin->plugin->type])
{
if ((*plugin_type_initialize[plugin->plugin->type])(plugin))
......@@ -1027,8 +1032,7 @@ static int plugin_initialize(struct st_plugin_int *plugin)
goto err;
}
}
plugin->state= PLUGIN_IS_READY;
state= PLUGIN_IS_READY; // plugin->init() succeeded
if (plugin->plugin->status_vars)
{
......@@ -1047,7 +1051,8 @@ static int plugin_initialize(struct st_plugin_int *plugin)
if (add_status_vars(array)) // add_status_vars makes a copy
goto err;
#else
add_status_vars(plugin->plugin->status_vars); // add_status_vars makes a copy
if (add_status_vars(plugin->plugin->status_vars))
goto err;
#endif /* FIX_LATER */
}
......@@ -1067,9 +1072,12 @@ static int plugin_initialize(struct st_plugin_int *plugin)
}
}
DBUG_RETURN(0);
ret= 0;
err:
DBUG_RETURN(1);
pthread_mutex_lock(&LOCK_plugin);
plugin->state= state;
DBUG_RETURN(ret);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment