Comment 1 for bug 1179136

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

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);
  }
}