diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 39d7f60527b46..eed6b31324b32 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5344,6 +5344,26 @@ static void test_lc_time_sz() #endif//DBUG_OFF +static void run_main_loop() +{ + select_thread=pthread_self(); + mysql_mutex_lock(&LOCK_start_thread); + select_thread_in_use=1; + mysql_mutex_unlock(&LOCK_start_thread); + +#ifdef _WIN32 + handle_connections_win(); +#else + handle_connections_sockets(); + + mysql_mutex_lock(&LOCK_start_thread); + select_thread_in_use=0; + mysql_cond_broadcast(&COND_start_thread); + mysql_mutex_unlock(&LOCK_start_thread); +#endif /* _WIN32 */ +} + + #ifdef __WIN__ int win_main(int argc, char **argv) #else @@ -5540,9 +5560,6 @@ int mysqld_main(int argc, char **argv) SYSVAR_AUTOSIZE(my_thread_stack_size, new_thread_stack_size); } - select_thread=pthread_self(); - select_thread_in_use=1; - #ifdef HAVE_LIBWRAP libwrapName= my_progname+dirname_length(my_progname); openlog(libwrapName, LOG_PID, LOG_AUTH); @@ -5596,7 +5613,6 @@ int mysqld_main(int argc, char **argv) // Recover and exit. if (wsrep_recovery) { - select_thread_in_use= 0; if (WSREP_ON) wsrep_recover(); else @@ -5671,7 +5687,6 @@ int mysqld_main(int argc, char **argv) if (opt_bootstrap) { - select_thread_in_use= 0; // Allow 'kill' to work int bootstrap_error= bootstrap(mysql_stdin); if (!abort_loop) unireg_abort(bootstrap_error); @@ -5751,16 +5766,7 @@ int mysqld_main(int argc, char **argv) /* Memory used when everything is setup */ start_memory_used= global_status_var.global_memory_used; -#ifdef _WIN32 - handle_connections_win(); -#else - handle_connections_sockets(); - - mysql_mutex_lock(&LOCK_start_thread); - select_thread_in_use=0; - mysql_cond_broadcast(&COND_start_thread); - mysql_mutex_unlock(&LOCK_start_thread); -#endif /* _WIN32 */ + run_main_loop(); /* Shutdown requested */ char *user= shutdown_user.load(std::memory_order_relaxed);