From 3503fbbebf90cb0fe63993a66dad9bf97fb74c0a Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Sun, 20 Jan 2019 02:32:35 +0400 Subject: Move THD list handling to THD_list Implemented and integrated THD_list as a replacement for the global thread list. It uses own mutex instead of LOCK_thread_count for THD list protection. Removed unused first_global_thread() and next_global_thread(). delayed_insert_threads is now protected by LOCK_delayed_insert. Although this patch doesn't fix very wrong synchronization of this variable. After this patch there are only 2 legitimate uses of LOCK_thread_count left, both in mysqld.cc: thread_count and ready_to_exit. Aim is to reduce usage of LOCK_thread_count and COND_thread_count. Part of MDEV-15135. --- libmysqld/lib_sql.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'libmysqld') diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index 715f1dde5b5..305f6346c9e 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -432,11 +432,9 @@ int emb_unbuffered_fetch(MYSQL *mysql, char **row) static void emb_free_embedded_thd(MYSQL *mysql) { THD *thd= (THD*)mysql->thd; - mysql_mutex_lock(&LOCK_thread_count); + server_threads.erase(thd); thd->clear_data_list(); thd->store_globals(); - thd->unlink(); - mysql_mutex_unlock(&LOCK_thread_count); delete thd; my_pthread_setspecific_ptr(THR_THD, 0); mysql->thd=0; @@ -711,10 +709,7 @@ void *create_embedded_thd(int client_flag) thd->first_data= 0; thd->data_tail= &thd->first_data; bzero((char*) &thd->net, sizeof(thd->net)); - - mysql_mutex_lock(&LOCK_thread_count); - threads.append(thd); - mysql_mutex_unlock(&LOCK_thread_count); + server_threads.insert(thd); thd->mysys_var= 0; thd->reset_globals(); return thd; -- cgit v1.2.1