mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
----------------------------------------------------------
revno: 2630.2.16 committer: Konstantin Osipov <konstantin@mysql.com> branch nick: mysql-6.0-runtime timestamp: Fri 2008-06-27 13:26:03 +0400 message: Fix max_user_connections_func failure on Solaris. A connection that failed to log in due to a resource limit could be returned to the thread pool with a dangling link to user_connect structure of an old user. Later on it could be authenticated to a user that doesn't have a resource limit, so this dangling link won't be reset. --pool-of-threads mode made the situation easy to reproduce, and thus highlighted a bug that has been around forever. Make sure there are no dangling links.
This commit is contained in:
@@ -151,7 +151,15 @@ int check_for_max_user_connections(THD *thd, USER_CONN *uc)
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
if (error)
|
if (error)
|
||||||
|
{
|
||||||
uc->connections--; // no need for decrease_user_connections() here
|
uc->connections--; // no need for decrease_user_connections() here
|
||||||
|
/*
|
||||||
|
The thread may returned back to the pool and assigned to a user
|
||||||
|
that doesn't have a limit. Ensure the user is not using resources
|
||||||
|
of someone else.
|
||||||
|
*/
|
||||||
|
thd->user_connect= NULL;
|
||||||
|
}
|
||||||
(void) pthread_mutex_unlock(&LOCK_user_conn);
|
(void) pthread_mutex_unlock(&LOCK_user_conn);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@@ -462,7 +470,10 @@ check_user(THD *thd, enum enum_server_command command,
|
|||||||
{
|
{
|
||||||
/* mysql_change_db() has pushed the error message. */
|
/* mysql_change_db() has pushed the error message. */
|
||||||
if (thd->user_connect)
|
if (thd->user_connect)
|
||||||
|
{
|
||||||
decrease_user_connections(thd->user_connect);
|
decrease_user_connections(thd->user_connect);
|
||||||
|
thd->user_connect= 0;
|
||||||
|
}
|
||||||
DBUG_RETURN(1);
|
DBUG_RETURN(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -975,7 +986,15 @@ static void end_connection(THD *thd)
|
|||||||
NET *net= &thd->net;
|
NET *net= &thd->net;
|
||||||
plugin_thdvar_cleanup(thd);
|
plugin_thdvar_cleanup(thd);
|
||||||
if (thd->user_connect)
|
if (thd->user_connect)
|
||||||
|
{
|
||||||
decrease_user_connections(thd->user_connect);
|
decrease_user_connections(thd->user_connect);
|
||||||
|
/*
|
||||||
|
The thread may returned back to the pool and assigned to a user
|
||||||
|
that doesn't have a limit. Ensure the user is not using resources
|
||||||
|
of someone else.
|
||||||
|
*/
|
||||||
|
thd->user_connect= NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (thd->killed || net->error && net->vio != 0)
|
if (thd->killed || net->error && net->vio != 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user