234
234
static uint32_t wake_thread;
235
235
static uint32_t killed_threads, thread_created;
236
236
static uint32_t max_used_connections;
237
static char *mysqld_user, *mysqld_chroot, *log_error_file_ptr;
237
static char *drizzled_user, *drizzled_chroot, *log_error_file_ptr;
238
238
static char *opt_init_slave, *language_ptr, *opt_init_connect;
239
239
static char *default_character_set_name;
240
240
static char *character_set_filesystem_name;
297
297
#ifdef HAVE_INITGROUPS
298
298
static bool calling_initgroups= false; /**< Used in SIGSEGV handler. */
300
uint32_t mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options;
301
uint32_t mysqld_port_timeout;
300
uint32_t drizzled_port, test_flags, select_errors, dropping_tables, ha_open_options;
301
uint32_t drizzled_port_timeout;
302
302
uint32_t delay_key_write_options, protocol_version;
303
303
uint32_t lower_case_table_names= 1;
304
304
uint32_t tc_heuristic_recover= 0;
471
471
static uint32_t opt_myisam_block_size;
472
472
static char *opt_binlog_index_name;
473
473
static char *opt_tc_heuristic_recover;
474
static char *mysql_home_ptr, *pidfile_name_ptr;
474
static char *drizzle_home_ptr, *pidfile_name_ptr;
475
475
static int defaults_argc;
476
476
static char **defaults_argv;
477
477
static char *opt_bin_logname;
497
497
/* Function declarations */
499
499
pthread_handler_t signal_hand(void *arg);
500
static void mysql_init_variables(void);
500
static void drizzle_init_variables(void);
501
501
static void get_options(int *argc,char **argv);
502
502
extern "C" bool mysqld_get_one_option(int, const struct my_option *, char *);
503
503
static void set_server_version(void);
518
518
static void clean_up_mutexes(void);
519
519
static void wait_for_signal_thread_to_end(void);
520
520
static void create_pid_file();
521
static void mysqld_exit(int exit_code) __attribute__((noreturn));
521
static void drizzled_exit(int exit_code) __attribute__((noreturn));
523
523
/****************************************************************************
524
524
** Code to end mysqld
797
797
else if (opt_help)
799
799
clean_up(!opt_help && (exit_code)); /* purecov: inspected */
800
mysqld_exit(exit_code);
800
drizzled_exit(exit_code);
804
static void mysqld_exit(int exit_code)
804
static void drizzled_exit(int exit_code)
806
806
wait_for_signal_thread_to_end();
807
807
clean_up_mutexes();
932
932
static void set_ports()
936
936
{ // Get port if not from commandline
937
mysqld_port= DRIZZLE_PORT;
937
drizzled_port= DRIZZLE_PORT;
940
940
if builder specifically requested a default port, use that
949
949
struct servent *serv_ptr;
950
950
if ((serv_ptr= getservbyname("drizzle", "tcp")))
951
mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
951
drizzled_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */
953
953
if ((env = getenv("DRIZZLE_TCP_PORT")))
954
mysqld_port= (uint) atoi(env); /* purecov: inspected */
954
drizzled_port= (uint) atoi(env); /* purecov: inspected */
956
assert(drizzled_port);
1100
1100
hints.ai_flags= AI_PASSIVE;
1101
1101
hints.ai_socktype= SOCK_STREAM;
1103
snprintf(port_buf, NI_MAXSERV, "%d", mysqld_port);
1103
snprintf(port_buf, NI_MAXSERV, "%d", drizzled_port);
1104
1104
error= getaddrinfo(my_bind_addr_str, port_buf, &hints, &ai);
1105
1105
if (error != 0)
1173
1173
on busy Linux systems. Retry to bind the address at these intervals:
1174
1174
Sleep intervals: 1, 2, 4, 6, 9, 13, 17, 22, ...
1175
1175
Retry at second: 1, 3, 7, 13, 22, 35, 52, 74, ...
1176
Limit the sequence by mysqld_port_timeout (set --port-open-timeout=#).
1176
Limit the sequence by drizzled_port_timeout (set --port-open-timeout=#).
1178
1178
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
1180
1180
if (((ret= bind(ip_sock, next->ai_addr, next->ai_addrlen)) >= 0 ) ||
1181
1181
(errno != EADDRINUSE) ||
1182
(waited >= mysqld_port_timeout))
1182
(waited >= drizzled_port_timeout))
1184
sql_print_information(_("Retrying bind on TCP/IP port %u"), mysqld_port);
1184
sql_print_information(_("Retrying bind on TCP/IP port %u"), drizzled_port);
1185
1185
this_wait= retry * retry / 3 + 1;
1186
1186
sleep(this_wait);
1190
1190
sql_perror(_("Can't start server: Bind on TCP/IP port"));
1191
1191
sql_print_error(_("Do you already have another drizzled server running "
1192
"on port: %d ?"),mysqld_port);
1192
"on port: %d ?"),drizzled_port);
1193
1193
unireg_abort(1);
1195
1195
if (listen(ip_sock,(int) back_log) < 0)
2498
2498
mysql_data_home[1]=0;
2499
2499
mysql_data_home_len= 2;
2501
if ((user_info= check_user(mysqld_user)))
2501
if ((user_info= check_user(drizzled_user)))
2503
2503
#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT)
2504
2504
if (locked_in_memory) // getuid() == 0 here
2505
2505
set_effective_user(user_info);
2508
set_user(mysqld_user, user_info);
2508
set_user(drizzled_user, user_info);
2511
2511
if (opt_bin_log && !server_id)
2563
2563
sql_print_information(_(ER(ER_STARTUP)),my_progname,server_version,
2564
"", mysqld_port, COMPILATION_COMMENT);
2564
"", drizzled_port, COMPILATION_COMMENT);
2567
2567
handle_connections_sockets();
2938
2938
{"basedir", 'b',
2939
2939
N_("Path to installation directory. All paths are usually resolved "
2940
2940
"relative to this."),
2941
(char**) &mysql_home_ptr, (char**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG,
2941
(char**) &drizzle_home_ptr, (char**) &drizzle_home_ptr, 0, GET_STR, REQUIRED_ARG,
2942
2942
0, 0, 0, 0, 0, 0},
2943
2943
{"bind-address", OPT_BIND_ADDRESS, N_("IP address to bind to."),
2944
2944
(char**) &my_bind_addr_str, (char**) &my_bind_addr_str, 0, GET_STR,
2991
2991
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
2992
2992
{"chroot", 'r',
2993
2993
N_("Chroot mysqld daemon during startup."),
2994
(char**) &mysqld_chroot, (char**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG,
2994
(char**) &drizzled_chroot, (char**) &drizzled_chroot, 0, GET_STR, REQUIRED_ARG,
2995
2995
0, 0, 0, 0, 0, 0},
2996
2996
{"collation-server", OPT_DEFAULT_COLLATION,
2997
2997
N_("Set the default collation."),
3174
3174
N_("Port number to use for connection or 0 for default to, in "
3175
3175
"order of preference, drizzle.cnf, $DRIZZLE_TCP_PORT, "
3176
3176
"built-in default (" STRINGIFY_ARG(DRIZZLE_PORT) ")."),
3177
(char**) &mysqld_port,
3178
(char**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3177
(char**) &drizzled_port,
3178
(char**) &drizzled_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3179
3179
{"port-open-timeout", OPT_PORT_OPEN_TIMEOUT,
3180
3180
N_("Maximum time in seconds to wait for the port to become free. "
3181
3181
"(Default: no wait)"),
3182
(char**) &mysqld_port_timeout,
3183
(char**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3182
(char**) &drizzled_port_timeout,
3183
(char**) &drizzled_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3184
3184
{"relay-log", OPT_RELAY_LOG,
3185
3185
N_("The location and name to use for relay logs."),
3186
3186
(char**) &opt_relay_logname, (char**) &opt_relay_logname, 0,
3349
3349
0, 0, 0, GET_STR, REQUIRED_ARG, 0,
3350
3350
0, 0, 0, 0, 0},
3352
N_("Run mysqld daemon as user."),
3352
N_("Run drizzled daemon as user."),
3353
3353
0, 0, 0, GET_STR, REQUIRED_ARG,
3354
3354
0, 0, 0, 0, 0, 0},
3355
3355
{"version", 'V',
3639
3639
(char**) &opt_plugin_dir_ptr, (char**) &opt_plugin_dir_ptr, 0,
3640
3640
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3641
3641
{"plugin_load", OPT_PLUGIN_LOAD,
3642
N_("Optional comma separated list of plugins to load, where each plugin is "
3643
"identified by the name of the shared library. "
3644
"[for example: --plugin_load=libmd5udf.so]"),
3642
N_("Optional colon (or semicolon) separated list of plugins to load,"
3643
"where each plugin is identified by the name of the shared library. "
3644
"[for example: --plugin_load=libmd5udf.so:libauth_pam.so]"),
3645
3645
(char**) &opt_plugin_load, (char**) &opt_plugin_load, 0,
3646
3646
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
3647
3647
{"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
4078
4078
as these are initialized by my_getopt.
4081
static void mysql_init_variables(void)
4081
static void drizzle_init_variables(void)
4083
4083
/* Things reset to zero */
4084
4084
opt_skip_slave_start= opt_reckless_slave = 0;
4105
4105
specialflag= 0;
4106
4106
binlog_cache_use= binlog_cache_disk_use= 0;
4107
4107
max_used_connections= slow_launch_threads = 0;
4108
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
4108
drizzled_user= drizzled_chroot= opt_init_file= opt_bin_logname = 0;
4109
4109
opt_mysql_tmpdir= my_bind_addr_str= NULL;
4110
4110
memset(&mysql_tmpdir_list, 0, sizeof(mysql_tmpdir_list));
4111
4111
memset(&global_status_var, 0, sizeof(global_status_var));
4125
4125
slave_exec_mode_options= 0;
4126
4126
slave_exec_mode_options= (uint)
4127
4127
find_bit_type_or_exit(slave_exec_mode_str, &slave_exec_mode_typelib, NULL);
4128
mysql_home_ptr= mysql_home;
4128
drizzle_home_ptr= mysql_home;
4129
4129
pidfile_name_ptr= pidfile_name;
4130
4130
log_error_file_ptr= log_error_file;
4131
4131
language_ptr= language;
4230
4230
mysql_data_home_len= strlen(mysql_data_home);
4233
if (!mysqld_user || !strcmp(mysqld_user, argument))
4234
mysqld_user= argument;
4233
if (!drizzled_user || !strcmp(drizzled_user, argument))
4234
drizzled_user= argument;
4236
4236
sql_print_warning(_("Ignoring user change to '%s' because the user was "
4237
4237
"set to '%s' earlier on the command line\n"),
4238
argument, mysqld_user);
4238
argument, drizzled_user);
4241
4241
strmake(language, argument, sizeof(language)-1);