Split up unlink_thd in several functions

This commit is contained in:
Mikael Ronström 2011-05-18 09:38:05 +02:00
commit 89ec54264d
2 changed files with 35 additions and 8 deletions

View file

@ -94,8 +94,10 @@ bool thd_is_connection_alive(THD *thd);
void close_connection(THD *thd, uint errcode);
/* End the connection before closing it */
void end_connection(THD *thd);
/* Decrement connection counter */
void dec_connection_count();
/* Destroy THD object */
void unlink_thd(THD *thd);
void delete_thd(THD *thd);
/*
thread_created is maintained by thread pool when activated since

View file

@ -2009,6 +2009,36 @@ extern "C" sig_handler end_thread_signal(int sig __attribute__((unused)))
}
/*
Decrease number of connections
SYNOPSIS
dec_connection_count()
*/
void dec_connection_count()
{
mysql_mutex_lock(&LOCK_connection_count);
--connection_count;
mysql_mutex_unlock(&LOCK_connection_count);
}
/*
Delete the THD object and decrease number of threads
SYNOPSIS
delete_thd()
thd Thread handler
*/
void delete_thd(THD *thd)
{
thread_count--;
delete thd;
}
/*
Unlink thd from global list of available connections and free thd
@ -2024,15 +2054,10 @@ void unlink_thd(THD *thd)
{
DBUG_ENTER("unlink_thd");
DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
thd->cleanup();
mysql_mutex_lock(&LOCK_connection_count);
--connection_count;
mysql_mutex_unlock(&LOCK_connection_count);
dec_connection_count();
mysql_mutex_lock(&LOCK_thread_count);
thread_count--;
delete thd;
delete_thd(thd);
DBUG_VOID_RETURN;
}