Skip to content

Commit

Permalink
Change connection_count back to static
Browse files Browse the repository at this point in the history
Code structual change only, just limiting
super global variables especially when the
counter under the THD structure should be used
in general.
  • Loading branch information
grooverdan committed Jun 1, 2021
1 parent b118f92 commit 5727d56
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion sql/mysqld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions sql/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion sql/scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down

0 comments on commit 5727d56

Please sign in to comment.