diff options
-rw-r--r-- | sql/mysqld.cc | 12 | ||||
-rw-r--r-- | sql/threadpool.h | 2 | ||||
-rw-r--r-- | sql/threadpool_generic.cc | 4 | ||||
-rw-r--r-- | sql/threadpool_win.cc | 4 |
4 files changed, 16 insertions, 6 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a5f1d396ff5..a0cad67b2e6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7623,6 +7623,16 @@ int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff, *(int *)buff= tp_get_idle_thread_count(); return 0; } + + +static int show_threadpool_threads(THD *thd, SHOW_VAR *var, char *buff, + enum enum_var_type scope) +{ + var->type= SHOW_INT; + var->value= buff; + *(reinterpret_cast<int*>(buff))= tp_get_thread_count(); + return 0; +} #endif /* @@ -7842,7 +7852,7 @@ SHOW_VAR status_vars[]= { #endif #ifdef HAVE_POOL_OF_THREADS {"Threadpool_idle_threads", (char *) &show_threadpool_idle_threads, SHOW_SIMPLE_FUNC}, - {"Threadpool_threads", (char *) &tp_stats.num_worker_threads, SHOW_INT}, + {"Threadpool_threads", (char *) &show_threadpool_threads, SHOW_SIMPLE_FUNC}, #endif {"Threads_cached", (char*) &cached_thread_count, SHOW_LONG_NOFLUSH}, {"Threads_connected", (char*) &connection_count, SHOW_INT}, diff --git a/sql/threadpool.h b/sql/threadpool.h index 6299510d002..9145098be3f 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -47,7 +47,7 @@ extern void tp_timeout_handler(TP_connection *c); struct TP_STATISTICS { /* Current number of worker thread. */ - volatile int32 num_worker_threads; + Atomic_counter<uint32_t> num_worker_threads; }; extern TP_STATISTICS tp_stats; diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index 786fb5659c8..f128661ec60 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -908,7 +908,7 @@ static void add_thread_count(thread_group_t *thread_group, int32 count) thread_group->thread_count += count; /* worker starts out and end in "active" state */ thread_group->active_thread_count += count; - my_atomic_add32(&tp_stats.num_worker_threads, count); + tp_stats.num_worker_threads+= count; } @@ -928,7 +928,7 @@ static int create_worker(thread_group_t *thread_group) int err; DBUG_ENTER("create_worker"); - if (tp_stats.num_worker_threads >= (int)threadpool_max_threads + if (tp_stats.num_worker_threads >= threadpool_max_threads && thread_group->thread_count >= 2) { err= 1; diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 6e96fa8e11c..7d721c88f96 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -332,7 +332,7 @@ void tp_win_callback_prolog() /* Running in new worker thread*/ FlsSetValue(fls, (void *)1); statistic_increment(thread_created, &LOCK_status); - InterlockedIncrement((volatile long *)&tp_stats.num_worker_threads); + tp_stats.num_worker_threads++; my_thread_init(); } } @@ -355,7 +355,7 @@ static VOID WINAPI thread_destructor(void *data) { if(data) { - InterlockedDecrement((volatile long *)&tp_stats.num_worker_threads); + tp_stats.num_worker_threads--; my_thread_end(); } } |