The mutex is being destroyed at THD::~THD():
THD::~THD() { mysql_mutex_assert_not_owner(&LOCK_thread_count); ... mysql_mutex_destroy(&LOCK_thd_data); ...
The mutex is being held at thd_kill():
extern "C" void thd_kill(ulong id) { THD *tmp= NULL; mysql_mutex_lock(&LOCK_thread_count); Thread_iterator it= global_thread_list_begin(); Thread_iterator it_end= global_thread_list_end(); while (it != it_end) { tmp= *it; if (tmp->get_command() == COM_DAEMON) continue; if (tmp->thread_id == id) { mysql_mutex_lock(&tmp->LOCK_thd_data); mysql_mutex_unlock(&LOCK_thread_count); tmp->awake(THD::KILL_CONNECTION); mysql_mutex_unlock(&tmp->LOCK_thd_data); break; } it++; } if (it == it_end) { mysql_mutex_unlock(&LOCK_thread_count); } }
The mutex is being destroyed at THD::~THD():
THD::~THD() mutex_assert_ not_owner( &LOCK_thread_ count); mutex_destroy( &LOCK_thd_ data);
{
mysql_
...
mysql_
...
The mutex is being held at thd_kill():
extern "C" mutex_lock( &LOCK_thread_ count); thread_ list_begin( ); thread_ list_end( ); mutex_lock( &tmp->LOCK_ thd_data) ; mutex_unlock( &LOCK_thread_ count); >awake( THD::KILL_ CONNECTION) ; mutex_unlock( &tmp->LOCK_ thd_data) ; mutex_unlock( &LOCK_thread_ count);
void thd_kill(ulong id)
{
THD *tmp= NULL;
mysql_
Thread_iterator it= global_
Thread_iterator it_end= global_
while (it != it_end)
{
tmp= *it;
if (tmp->get_command() == COM_DAEMON)
continue;
if (tmp->thread_id == id)
{
mysql_
mysql_
tmp-
mysql_
break;
}
it++;
}
if (it == it_end)
{
mysql_
}
}