You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Fix for CONC-568:
If multiple threads attempt to connect to a server using a dynamically loaded authentication plugin the error "plugin is already loaded" might occur. This is caused by a race condition if one thread waits for a lock to load the plugin, while another process which obtained the lock already loaded the plugin. The API function mysql_load_plugin_v() now returns the plugin handle (instead of raising an error and returning a NULL handle) even if the plugin was already loaded.
This commit is contained in:
@@ -330,6 +330,7 @@ struct st_mysql_client_plugin * STDCALL
|
|||||||
mysql_client_register_plugin(MYSQL *mysql,
|
mysql_client_register_plugin(MYSQL *mysql,
|
||||||
struct st_mysql_client_plugin *plugin)
|
struct st_mysql_client_plugin *plugin)
|
||||||
{
|
{
|
||||||
|
struct st_mysql_client_plugin *found_plugin= NULL;
|
||||||
va_list unused;
|
va_list unused;
|
||||||
LINT_INIT_STRUCT(unused);
|
LINT_INIT_STRUCT(unused);
|
||||||
|
|
||||||
@@ -339,18 +340,11 @@ mysql_client_register_plugin(MYSQL *mysql,
|
|||||||
pthread_mutex_lock(&LOCK_load_client_plugin);
|
pthread_mutex_lock(&LOCK_load_client_plugin);
|
||||||
|
|
||||||
/* make sure the plugin wasn't loaded meanwhile */
|
/* make sure the plugin wasn't loaded meanwhile */
|
||||||
if (find_plugin(plugin->name, plugin->type))
|
if (!(found_plugin= find_plugin(plugin->name, plugin->type)))
|
||||||
{
|
found_plugin= add_plugin(mysql, plugin, 0, 0, unused);
|
||||||
my_set_error(mysql, CR_AUTH_PLUGIN_CANNOT_LOAD,
|
|
||||||
SQLSTATE_UNKNOWN, ER(CR_AUTH_PLUGIN_CANNOT_LOAD),
|
|
||||||
plugin->name, "it is already loaded");
|
|
||||||
plugin= NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
plugin= add_plugin(mysql, plugin, 0, 0, unused);
|
|
||||||
|
|
||||||
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
pthread_mutex_unlock(&LOCK_load_client_plugin);
|
||||||
return plugin;
|
return found_plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -4060,7 +4060,7 @@ my_bool mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *arg, ...
|
|||||||
*((char **)arg)= (char *)ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
*((char **)arg)= (char *)ma_pvio_tls_cipher(mysql->net.pvio->ctls);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
goto error;
|
*((char **)arg)= NULL;
|
||||||
break;
|
break;
|
||||||
case MARIADB_CLIENT_ERRORS:
|
case MARIADB_CLIENT_ERRORS:
|
||||||
*((char ***)arg)= (char **)client_errors;
|
*((char ***)arg)= (char **)client_errors;
|
||||||
|
Reference in New Issue
Block a user