summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Black <daniel@mariadb.org>2021-05-20 14:15:43 +1000
committerDaniel Black <daniel@mariadb.org>2021-06-01 13:53:16 +1000
commit5727d56260e66d9b9f2dee6783385c5928d4f3a3 (patch)
tree4070642e28c0024c35592b13fe0fa4970e0fb158
parentb118f92be6b8d7294f3b57f824559ced3dcccc6b (diff)
downloadmariadb-git-5727d56260e66d9b9f2dee6783385c5928d4f3a3.tar.gz
Change connection_count back to static
Code structual change only, just limiting super global variables especially when the counter under the THD structure should be used in general.
-rw-r--r--sql/mysqld.cc13
-rw-r--r--sql/mysqld.h1
-rw-r--r--sql/scheduler.cc5
-rw-r--r--sql/scheduler.h2
4 files changed, 13 insertions, 8 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 6eba8e11d58..491931b4732 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -1466,7 +1466,7 @@ struct st_VioSSLFd *ssl_acceptor_fd;
/**
Number of currently active user connections.
*/
-Atomic_counter<uint> connection_count;
+static Atomic_counter<uint> connection_count;
static Atomic_counter<uint> extra_connection_count;
my_bool opt_gtid_strict_mode= FALSE;
@@ -8571,15 +8571,20 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
return 1;
#ifdef EMBEDDED_LIBRARY
- one_thread_scheduler(thread_scheduler);
- one_thread_scheduler(extra_thread_scheduler);
+ one_thread_scheduler(thread_scheduler, &connection_count);
+ /*
+ It looks like extra_connection_count should be passed here but
+ its been using connection_count for the last 10+ years and
+ no-one was requested a change so lets not suprise anyone.
+ */
+ one_thread_scheduler(extra_thread_scheduler, &connection_count);
#else
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
one_thread_per_connection_scheduler(thread_scheduler, &max_connections,
&connection_count);
else if (thread_handling == SCHEDULER_NO_THREADS)
- one_thread_scheduler(thread_scheduler);
+ one_thread_scheduler(thread_scheduler, &connection_count);
else
pool_of_threads_scheduler(thread_scheduler, &max_connections,
&connection_count);
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 768b81d59fc..ff7060425cb 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -116,7 +116,6 @@ extern bool opt_ignore_builtin_innodb;
extern my_bool opt_character_set_client_handshake;
extern my_bool debug_assert_on_not_freed_memory;
extern MYSQL_PLUGIN_IMPORT bool volatile abort_loop;
-extern Atomic_counter<uint> connection_count;
extern my_bool opt_safe_user_create;
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index 7380b134f13..7261c5f39d7 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -131,11 +131,12 @@ void handle_connection_in_main_thread(CONNECT *connect)
Initialize scheduler for --thread-handling=no-threads
*/
-void one_thread_scheduler(scheduler_functions *func)
+void one_thread_scheduler(scheduler_functions *func,
+ Atomic_counter<uint> *arg_connection_count)
{
scheduler_init();
func->max_threads= 1;
func->max_connections= &max_connections;
- func->connection_count= &connection_count;
+ func->connection_count= arg_connection_count;
func->add_connection= handle_connection_in_main_thread;
}
diff --git a/sql/scheduler.h b/sql/scheduler.h
index 68387390d81..c2686aad21c 100644
--- a/sql/scheduler.h
+++ b/sql/scheduler.h
@@ -74,7 +74,7 @@ enum scheduler_types
void one_thread_per_connection_scheduler(scheduler_functions *func,
ulong *arg_max_connections, Atomic_counter<uint> *arg_connection_count);
-void one_thread_scheduler(scheduler_functions *func);
+void one_thread_scheduler(scheduler_functions *func, Atomic_counter<uint> *arg_connection_count);
extern void scheduler_init();
extern void post_kill_notification(THD *);