Commit 9644bc3e authored by petr@mysql.com's avatar petr@mysql.com

Post-review fixes for WL#2713 "Change IM behaviour so, that it only reads and...

Post-review fixes for WL#2713 "Change IM behaviour so, that it only reads and alters one config file only."
parent b9fcdfbb
...@@ -644,11 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg, ...@@ -644,11 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg,
if ((instance= instance_map->find(name, len))) if ((instance= instance_map->find(name, len)))
{ {
instance_name= instance->options.instance_name; 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 */ /* add prefix for add_option */
if ((option_len_arg < MAX_OPTION_LEN - 1) || if ((option_len_arg < MAX_OPTION_LEN - 1) ||
...@@ -696,12 +691,8 @@ int Set_option::correct_file(int skip) ...@@ -696,12 +691,8 @@ int Set_option::correct_file(int skip)
{ {
int error; int error;
if (single_defaults_file != NULL) error= modify_defaults_file(Options::config_file, option,
error= modify_defaults_file(single_defaults_file, option, option_value, instance_name, skip);
option_value, instance_name, skip);
else
error= modify_defaults_file(Options::default_config_file, option,
option_value, instance_name, skip);
switch (error) switch (error)
{ {
......
...@@ -187,7 +187,6 @@ class Set_option : public Command ...@@ -187,7 +187,6 @@ class Set_option : public Command
public: public:
const char *instance_name; const char *instance_name;
uint instance_name_len; uint instance_name_len;
const char *single_defaults_file;
/* buffer for the option */ /* buffer for the option */
enum { MAX_OPTION_LEN= 1024 }; enum { MAX_OPTION_LEN= 1024 };
char option[MAX_OPTION_LEN]; char option[MAX_OPTION_LEN];
......
...@@ -113,10 +113,8 @@ static int process_option(void *ctx, const char *group, const char *option) ...@@ -113,10 +113,8 @@ static int process_option(void *ctx, const char *group, const char *option)
C_MODE_END C_MODE_END
Instance_map::Instance_map(const char *default_mysqld_path_arg, Instance_map::Instance_map(const char *default_mysqld_path_arg):
const char *single_defaults_file_option_arg): mysqld_path(default_mysqld_path_arg)
mysqld_path(default_mysqld_path_arg),
single_defaults_file_option(single_defaults_file_option_arg)
{ {
pthread_mutex_init(&LOCK_instance_map, 0); pthread_mutex_init(&LOCK_instance_map, 0);
} }
...@@ -240,20 +238,13 @@ int Instance_map::load() ...@@ -240,20 +238,13 @@ int Instance_map::load()
/* the name of the program may be orbitrary here in fact */ /* the name of the program may be orbitrary here in fact */
argv_options[0]= "mysqlmanager"; argv_options[0]= "mysqlmanager";
if (single_defaults_file_option != NULL) argv_options[1]= '\0';
{
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 If the routine failed, we'll simply fallback to defaults in
complete_initialization(). 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, (char ***) &argv, &args_used,
process_option, (void*) this)) process_option, (void*) this))
log_info("Falling back to compiled-in defaults"); log_info("Falling back to compiled-in defaults");
......
...@@ -64,8 +64,7 @@ class Instance_map ...@@ -64,8 +64,7 @@ class Instance_map
int unlock(); int unlock();
int init(); int init();
Instance_map(const char *default_mysqld_path_arg, Instance_map(const char *default_mysqld_path_arg);
const char *single_defaults_file_option_arg);
~Instance_map(); ~Instance_map();
/* loads options from config files */ /* loads options from config files */
...@@ -77,7 +76,6 @@ class Instance_map ...@@ -77,7 +76,6 @@ class Instance_map
public: public:
const char *mysqld_path; const char *mysqld_path;
const char *single_defaults_file_option;
Guardian_thread *guardian; Guardian_thread *guardian;
private: private:
......
...@@ -68,8 +68,7 @@ void manager(const Options &options) ...@@ -68,8 +68,7 @@ void manager(const Options &options)
*/ */
User_map user_map; User_map user_map;
Instance_map instance_map(options.default_mysqld_path, Instance_map instance_map(options.default_mysqld_path);
options.single_defaults_file_option);
Guardian_thread guardian_thread(thread_registry, Guardian_thread guardian_thread(thread_registry,
&instance_map, &instance_map,
options.monitoring_interval); options.monitoring_interval);
......
...@@ -36,8 +36,7 @@ const char *Options::pid_file_name= QUOTE(DEFAULT_PID_FILE_NAME); ...@@ -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::socket_file_name= QUOTE(DEFAULT_SOCKET_FILE_NAME);
const char *Options::password_file_name= QUOTE(DEFAULT_PASSWORD_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_mysqld_path= QUOTE(DEFAULT_MYSQLD_PATH);
const char *Options::default_config_file= QUOTE(DEFAULT_CONFIG_FILE); const char *Options::config_file= QUOTE(DEFAULT_CONFIG_FILE);
const char *Options::single_defaults_file_option= 0; /* No default value */
const char *Options::bind_address= 0; /* No default value */ const char *Options::bind_address= 0; /* No default value */
const char *Options::user= 0; /* No default value */ const char *Options::user= 0; /* No default value */
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL; uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
...@@ -144,7 +143,12 @@ static void usage() ...@@ -144,7 +143,12 @@ static void usage()
printf("Usage: %s [OPTIONS] \n", my_progname); printf("Usage: %s [OPTIONS] \n", my_progname);
my_print_help(my_long_options); 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); my_print_variables(my_long_options);
} }
...@@ -216,58 +220,37 @@ C_MODE_END ...@@ -216,58 +220,37 @@ C_MODE_END
int Options::load(int argc, char **argv) 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; 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=")) if (is_prefix(argv[1], "--defaults-file="))
{ {
/* set --defaults-file, so that we read only this file */ Options::config_file= strchr(argv[1], '=') + 1;
Options::single_defaults_file_option= argv[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 */ /* the log is not enabled yet */
fprintf(stderr, "--defaults-extra-file is not supported by IM." fprintf(stderr, "The --defaults-extra-file and --no-defaults options"
" Skipping the option. \n"); " are not supported by\n"
original_argc--; "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 */ /* 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); &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) get_one_option)) != 0)
goto err; goto err;
return 0; return 0;
err: err:
return rc; return 1;
} }
void Options::cleanup() void Options::cleanup()
......
...@@ -36,11 +36,10 @@ struct Options ...@@ -36,11 +36,10 @@ struct Options
static const char *default_mysqld_path; static const char *default_mysqld_path;
static const char *user; static const char *user;
/* the option which should be passed to process_default_option_files */ /* the option which should be passed to process_default_option_files */
static const char *single_defaults_file_option;
static uint monitoring_interval; static uint monitoring_interval;
static uint port_number; static uint port_number;
static const char *bind_address; 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() */ /* argv pointer returned by load_defaults() to be used by free_defaults() */
static char **saved_argv; static char **saved_argv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment