diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-20 02:32:35 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2019-01-28 17:39:07 +0400 |
commit | 3503fbbebf90cb0fe63993a66dad9bf97fb74c0a (patch) | |
tree | 1c39a1f4d4d694a8b2d1166cae48050fe82b6c1c /sql/threadpool_generic.cc | |
parent | 891be49a36ebb951cd90d64d1b4c1cc633af1fdf (diff) | |
download | mariadb-git-3503fbbebf90cb0fe63993a66dad9bf97fb74c0a.tar.gz |
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.
Diffstat (limited to 'sql/threadpool_generic.cc')
-rw-r--r-- | sql/threadpool_generic.cc | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index 641d01645ba..e37fd6f0cf4 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -578,43 +578,24 @@ static void queue_put(thread_group_t *thread_group, native_event *ev, int cnt) Also, recalculate time when next timeout check should run. */ -static void timeout_check(pool_timer_t *timer) +static my_bool timeout_check(THD *thd, pool_timer_t *timer) { DBUG_ENTER("timeout_check"); - - mysql_mutex_lock(&LOCK_thread_count); - I_List_iterator<THD> it(threads); - - /* Reset next timeout check, it will be recalculated in the loop below */ - my_atomic_fas64((volatile int64*)&timer->next_timeout_check, ULONGLONG_MAX); - - THD *thd; - while ((thd=it++)) + if (thd->net.reading_or_writing == 1) { - if (thd->net.reading_or_writing != 1) - continue; - - TP_connection_generic *connection= (TP_connection_generic *)thd->event_scheduler.data; - if (!connection) - { - /* - Connection does not have scheduler data. This happens for example - if THD belongs to a different scheduler, that is listening to extra_port. - */ - continue; - } - - if(connection->abs_wait_timeout < timer->current_microtime) - { - tp_timeout_handler(connection); - } - else + /* + Check if connection does not have scheduler data. This happens for example + if THD belongs to a different scheduler, that is listening to extra_port. + */ + if (auto connection= (TP_connection_generic *) thd->event_scheduler.data) { - set_next_timeout_check(connection->abs_wait_timeout); + if (connection->abs_wait_timeout < timer->current_microtime) + tp_timeout_handler(connection); + else + set_next_timeout_check(connection->abs_wait_timeout); } } - mysql_mutex_unlock(&LOCK_thread_count); - DBUG_VOID_RETURN; + DBUG_RETURN(0); } @@ -671,7 +652,12 @@ static void* timer_thread(void *param) /* Check if any client exceeded wait_timeout */ if (timer->next_timeout_check <= timer->current_microtime) - timeout_check(timer); + { + /* Reset next timeout check, it will be recalculated below */ + my_atomic_fas64((volatile int64*) &timer->next_timeout_check, + ULONGLONG_MAX); + server_threads.iterate(timeout_check, timer); + } } mysql_mutex_unlock(&timer->mutex); } |