1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

remove find_thread_with_thd_data_lock_callback

let the caller take the lock if needed
This commit is contained in:
Sergei Golubchik
2021-02-12 15:05:24 +01:00
parent eac8341df4
commit 259b945204
3 changed files with 9 additions and 25 deletions

View File

@ -9098,24 +9098,6 @@ THD *find_thread_by_id(longlong id, bool query_id)
return arg.thd;
}
static my_bool find_thread_with_thd_data_lock_callback(THD *thd, find_thread_callback_arg *arg)
{
if (arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id))
{
mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete
mysql_mutex_lock(&thd->LOCK_thd_data); // XXX DELME
arg->thd= thd;
return 1;
}
return 0;
}
THD *find_thread_by_id_with_thd_data_lock(longlong id, bool query_id)
{
find_thread_callback_arg arg(id, query_id);
server_threads.iterate(find_thread_with_thd_data_lock_callback, &arg);
return arg.thd;
}
/**
kill one thread.
@ -9132,7 +9114,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
uint error= (type == KILL_TYPE_QUERY ? ER_NO_SUCH_QUERY : ER_NO_SUCH_THREAD);
DBUG_ENTER("kill_one_thread");
DBUG_PRINT("enter", ("id: %lld signal: %u", id, (uint) kill_signal));
tmp= find_thread_by_id_with_thd_data_lock(id, type == KILL_TYPE_QUERY);
tmp= find_thread_by_id(id, type == KILL_TYPE_QUERY);
if (!tmp)
DBUG_RETURN(error);
@ -9159,6 +9141,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
faster and do a harder kill than KILL_SYSTEM_THREAD;
*/
mysql_mutex_lock(&tmp->LOCK_thd_data); // for various wsrep* checks below
#ifdef WITH_WSREP
if (((thd->security_ctx->master_access & SUPER_ACL) ||
thd->security_ctx->user_matches(tmp->security_ctx)) &&
@ -9180,8 +9163,8 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
else
#endif /* WITH_WSREP */
{
WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d",
thd->thread_id, id, tmp->wsrep_aborter, kill_signal);
WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d",
thd->thread_id, id, tmp->wsrep_aborter, kill_signal);
tmp->awake_no_mutex(kill_signal);
WSREP_DEBUG("victim: %llu taken care of", id);
error= 0;
@ -9190,9 +9173,9 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ
else
error= (type == KILL_TYPE_QUERY ? ER_KILL_QUERY_DENIED_ERROR :
ER_KILL_DENIED_ERROR);
mysql_mutex_unlock(&tmp->LOCK_thd_data);
}
mysql_mutex_unlock(&tmp->LOCK_thd_kill);
mysql_mutex_unlock(&tmp->LOCK_thd_data);
DBUG_PRINT("exit", ("%d", error));
DBUG_RETURN(error);
}