mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Post-review fixes for WL#2713 "Change IM behaviour so, that it only reads and alters one config file only."
This commit is contained in:
@ -644,11 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg,
|
||||
if ((instance= instance_map->find(name, len)))
|
||||
{
|
||||
instance_name= instance->options.instance_name;
|
||||
if (instance_map->single_defaults_file_option != NULL)
|
||||
single_defaults_file=
|
||||
strchr(instance_map->single_defaults_file_option, '=') + 1;
|
||||
else
|
||||
single_defaults_file= NULL;
|
||||
|
||||
/* add prefix for add_option */
|
||||
if ((option_len_arg < MAX_OPTION_LEN - 1) ||
|
||||
@ -696,11 +691,7 @@ int Set_option::correct_file(int skip)
|
||||
{
|
||||
int error;
|
||||
|
||||
if (single_defaults_file != NULL)
|
||||
error= modify_defaults_file(single_defaults_file, option,
|
||||
option_value, instance_name, skip);
|
||||
else
|
||||
error= modify_defaults_file(Options::default_config_file, option,
|
||||
error= modify_defaults_file(Options::config_file, option,
|
||||
option_value, instance_name, skip);
|
||||
|
||||
switch (error)
|
||||
|
@ -187,7 +187,6 @@ protected:
|
||||
public:
|
||||
const char *instance_name;
|
||||
uint instance_name_len;
|
||||
const char *single_defaults_file;
|
||||
/* buffer for the option */
|
||||
enum { MAX_OPTION_LEN= 1024 };
|
||||
char option[MAX_OPTION_LEN];
|
||||
|
@ -113,10 +113,8 @@ err_new_instance:
|
||||
C_MODE_END
|
||||
|
||||
|
||||
Instance_map::Instance_map(const char *default_mysqld_path_arg,
|
||||
const char *single_defaults_file_option_arg):
|
||||
mysqld_path(default_mysqld_path_arg),
|
||||
single_defaults_file_option(single_defaults_file_option_arg)
|
||||
Instance_map::Instance_map(const char *default_mysqld_path_arg):
|
||||
mysqld_path(default_mysqld_path_arg)
|
||||
{
|
||||
pthread_mutex_init(&LOCK_instance_map, 0);
|
||||
}
|
||||
@ -240,20 +238,13 @@ int Instance_map::load()
|
||||
|
||||
/* the name of the program may be orbitrary here in fact */
|
||||
argv_options[0]= "mysqlmanager";
|
||||
if (single_defaults_file_option != NULL)
|
||||
{
|
||||
argc= 2;
|
||||
argv_options[1]= single_defaults_file_option;
|
||||
argv_options[2]= '\0';
|
||||
}
|
||||
else
|
||||
argv_options[1]= '\0';
|
||||
|
||||
/*
|
||||
If the routine failed, we'll simply fallback to defaults in
|
||||
complete_initialization().
|
||||
*/
|
||||
if (my_search_option_files(Options::default_config_file, &argc,
|
||||
if (my_search_option_files(Options::config_file, &argc,
|
||||
(char ***) &argv, &args_used,
|
||||
process_option, (void*) this))
|
||||
log_info("Falling back to compiled-in defaults");
|
||||
|
@ -64,8 +64,7 @@ public:
|
||||
int unlock();
|
||||
int init();
|
||||
|
||||
Instance_map(const char *default_mysqld_path_arg,
|
||||
const char *single_defaults_file_option_arg);
|
||||
Instance_map(const char *default_mysqld_path_arg);
|
||||
~Instance_map();
|
||||
|
||||
/* loads options from config files */
|
||||
@ -77,7 +76,6 @@ public:
|
||||
|
||||
public:
|
||||
const char *mysqld_path;
|
||||
const char *single_defaults_file_option;
|
||||
Guardian_thread *guardian;
|
||||
|
||||
private:
|
||||
|
@ -68,8 +68,7 @@ void manager(const Options &options)
|
||||
*/
|
||||
|
||||
User_map user_map;
|
||||
Instance_map instance_map(options.default_mysqld_path,
|
||||
options.single_defaults_file_option);
|
||||
Instance_map instance_map(options.default_mysqld_path);
|
||||
Guardian_thread guardian_thread(thread_registry,
|
||||
&instance_map,
|
||||
options.monitoring_interval);
|
||||
|
@ -36,8 +36,7 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME);
|
||||
const char *Options::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
|
||||
const char *Options::password_file_name= QUOTE(DEFAULT_PASSWORD_FILE_NAME);
|
||||
const char *Options::default_mysqld_path= QUOTE(DEFAULT_MYSQLD_PATH);
|
||||
const char *Options::default_config_file= QUOTE(DEFAULT_CONFIG_FILE);
|
||||
const char *Options::single_defaults_file_option= 0; /* No default value */
|
||||
const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
|
||||
const char *Options::bind_address= 0; /* No default value */
|
||||
const char *Options::user= 0; /* No default value */
|
||||
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
|
||||
@ -144,7 +143,12 @@ static void usage()
|
||||
printf("Usage: %s [OPTIONS] \n", my_progname);
|
||||
|
||||
my_print_help(my_long_options);
|
||||
print_defaults("my", default_groups);
|
||||
printf("\nThe following options may be given as the first argument:\n"
|
||||
"--print-defaults Print the program argument list and exit\n"
|
||||
"--defaults-file=# Only read manager configuration and instance\n"
|
||||
" setings from the given file #. The same file\n"
|
||||
" will be used to modify configuration of instances\n"
|
||||
" with SET commands.\n");
|
||||
my_print_variables(my_long_options);
|
||||
}
|
||||
|
||||
@ -216,58 +220,37 @@ C_MODE_END
|
||||
|
||||
int Options::load(int argc, char **argv)
|
||||
{
|
||||
int rc;
|
||||
char **original_argv;
|
||||
int original_argc;
|
||||
char *original_argv_buff[1024];
|
||||
int use_new_argv= 0;
|
||||
|
||||
saved_argv= argv;
|
||||
original_argv= original_argv_buff;
|
||||
original_argc= argc;
|
||||
|
||||
if (argc >= 2 && is_prefix(argv[1],"--defaults-file="))
|
||||
if (argc >= 2)
|
||||
{
|
||||
if (is_prefix(argv[1], "--defaults-file="))
|
||||
{
|
||||
/* set --defaults-file, so that we read only this file */
|
||||
Options::single_defaults_file_option= argv[1];
|
||||
Options::config_file= strchr(argv[1], '=') + 1;
|
||||
}
|
||||
if (is_prefix(argv[1],"--defaults-extra-file="))
|
||||
if (is_prefix(argv[1], "--defaults-extra-file=") ||
|
||||
is_prefix(argv[1], "--no-defaults"))
|
||||
{
|
||||
int argv_pos= 1;
|
||||
|
||||
original_argv[0]= argv[0];
|
||||
use_new_argv= 1;
|
||||
/* skip --defaullts-extra-file */
|
||||
while (++argv_pos != argc)
|
||||
original_argv[argv_pos]=argv[argv_pos];
|
||||
original_argv[argv_pos]= 0;
|
||||
/* the log is not enabled yet */
|
||||
fprintf(stderr, "--defaults-extra-file is not supported by IM."
|
||||
" Skipping the option. \n");
|
||||
original_argc--;
|
||||
fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
|
||||
" are not supported by\n"
|
||||
"Instance Manager. Program aborted.\n");
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* here load_defaults will save pointer to free allocated memory */
|
||||
if (use_new_argv)
|
||||
saved_argv= original_argv;
|
||||
else
|
||||
saved_argv= argv;
|
||||
|
||||
/* config-file options are prepended to command-line ones */
|
||||
load_defaults(default_config_file, default_groups, &original_argc,
|
||||
load_defaults(config_file, default_groups, &argc,
|
||||
&saved_argv);
|
||||
|
||||
if ((rc= handle_options(&original_argc, &saved_argv, my_long_options,
|
||||
if ((handle_options(&argc, &saved_argv, my_long_options,
|
||||
get_one_option)) != 0)
|
||||
goto err;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
return rc;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Options::cleanup()
|
||||
|
@ -36,11 +36,10 @@ struct Options
|
||||
static const char *default_mysqld_path;
|
||||
static const char *user;
|
||||
/* the option which should be passed to process_default_option_files */
|
||||
static const char *single_defaults_file_option;
|
||||
static uint monitoring_interval;
|
||||
static uint port_number;
|
||||
static const char *bind_address;
|
||||
static const char *default_config_file;
|
||||
static const char *config_file;
|
||||
|
||||
/* argv pointer returned by load_defaults() to be used by free_defaults() */
|
||||
static char **saved_argv;
|
||||
|
Reference in New Issue
Block a user