1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

made IM to work with --defaults-file smoothly

BitKeeper/deleted/.del-my.cnf~9322f78f12eb2f3c:
  Delete: support-files/my.cnf
include/my_sys.h:
  fixed prototype to reflect changes in default.c
mysys/default.c:
  use my_search_option_files instead of process_default_option_files. This is used from the IM.
server-tools/instance-manager/instance.cc:
  added parameter to complete_initialization(). this ine marks whether we are creating the only instance
  (for instance, when no config file given)
server-tools/instance-manager/instance.h:
  prototype changed
server-tools/instance-manager/instance_map.cc:
  Now call my_search_option_files to work smootly with --defaults-file
server-tools/instance-manager/instance_map.h:
  added first_option member. This is set of mysqlmanager was started with --defaults-file or with
  --extra-defaults-file to be passed to the my_search_option_files
server-tools/instance-manager/instance_options.cc:
  if we have only one instance, name the pidfile `hostname`.pid for compatibility reasons.
server-tools/instance-manager/instance_options.h:
  header fixed according to .cc
server-tools/instance-manager/manager.cc:
  prototype fixed
server-tools/instance-manager/options.cc:
  save --defaults-file of --defaults-extra-file to pass it to my_search_option_files
server-tools/instance-manager/options.h:
  added an optin to save --default-file options
support-files/Makefile.am:
  revert changes
This commit is contained in:
unknown
2005-02-18 14:58:30 +03:00
parent 31bec29263
commit e2d78b85bf
13 changed files with 70 additions and 61 deletions

View File

@ -297,8 +297,9 @@ int Instance::init(const char *name_arg)
int Instance::complete_initialization(Instance_map *instance_map_arg,
const char *mysqld_path)
const char *mysqld_path,
int only_instance)
{
instance_map= instance_map_arg;
return options.complete_initialization(mysqld_path);
return options.complete_initialization(mysqld_path, only_instance);
}

View File

@ -35,7 +35,7 @@ public:
~Instance();
int init(const char *name);
int complete_initialization(Instance_map *instance_map_arg,
const char *mysqld_path);
const char *mysqld_path, int only_instance= 0);
bool is_running();
int start();

View File

@ -110,10 +110,10 @@ err_new_instance:
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 *first_option_arg):
mysqld_path(default_mysqld_path_arg), first_option(first_option_arg)
{
mysqld_path= default_mysqld_path_arg;
pthread_mutex_init(&LOCK_instance_map, 0);
}
@ -193,9 +193,10 @@ int Instance_map::complete_initialization()
/*
After an instance have been added to the instance_map,
hash_free should handle it's deletion.
hash_free should handle it's deletion => goto err, not
err_instance.
*/
if (instance->complete_initialization(this, mysqld_path))
if (instance->complete_initialization(this, mysqld_path, 1))
goto err;
}
else
@ -220,7 +221,25 @@ err_instance:
int Instance_map::load()
{
if (process_default_option_files("my", process_option, (void *) this) ||
int argc= 1;
/* this is a dummy variable for search_option_files() */
uint args_used= 0;
const char *argv_options[3];
char **argv= (char **) &argv_options;
/* the name of the program may be orbitrary here in fact */
argv_options[0]= "mysqlmanager";
if (first_option != NULL)
{
argc= 2;
argv_options[1]= first_option;
argv_options[2]= '\0';
}
else
argv_options[1]= '\0';
if (my_search_option_files("my", &argc, (char ***) &argv, &args_used,
process_option, (void *) this) ||
complete_initialization())
return 1;

View File

@ -64,7 +64,8 @@ public:
int unlock();
int init();
Instance_map(const char *default_mysqld_path_arg);
Instance_map(const char *default_mysqld_path_arg,
const char *first_option_arg);
~Instance_map();
/* loads options from config files */
@ -79,6 +80,7 @@ public:
Guardian_thread *guardian;
private:
const char *first_option;
enum { START_HASH_SIZE = 16 };
pthread_mutex_t LOCK_instance_map;
HASH hash;

View File

@ -123,7 +123,8 @@ pid_t Instance_options::get_pid()
}
int Instance_options::complete_initialization(const char *default_path)
int Instance_options::complete_initialization(const char *default_path,
int only_instance)
{
const char *tmp;
@ -140,11 +141,23 @@ int Instance_options::complete_initialization(const char *default_path)
{
char pidfilename[MAX_PATH_LEN];
char hostname[MAX_PATH_LEN];
/*
If we created only one istance [mysqld], because no config. files were
found, we would like to model mysqld pid file values.
*/
if (!gethostname(hostname, sizeof(hostname) - 1))
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", hostname, "-",
instance_name, ".pid", NullS);
(only_instance == 0) ?
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name, "-",
hostname, ".pid", NullS):
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", hostname,
".pid", NullS);
else
(only_instance == 0) ?
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name,
".pid", NullS):
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", "mysql",
".pid", NullS);
add_option(pidfilename);

View File

@ -43,7 +43,7 @@ public:
{}
~Instance_options();
/* fills in argv */
int complete_initialization(const char *default_path);
int complete_initialization(const char *default_path, int only_instance);
int add_option(const char* option);
int init(const char *instance_name_arg);

View File

@ -67,7 +67,7 @@ void manager(const Options &options)
*/
User_map user_map;
Instance_map instance_map(options.default_mysqld_path);
Instance_map instance_map(options.default_mysqld_path, options.first_option);
Guardian_thread guardian_thread(thread_registry,
&instance_map,
options.monitoring_interval);

View File

@ -37,6 +37,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::first_option= 0; /* No default value */
const char *Options::bind_address= 0; /* No default value */
const char *Options::user= 0; /* No default value */
uint Options::monitoring_interval= DEFAULT_MONITORING_INTERVAL;
@ -210,10 +211,18 @@ C_MODE_END
int Options::load(int argc, char **argv)
{
int rc;
if (argc >= 2)
{
if (is_prefix(argv[1],"--defaults-file=") ||
is_prefix(argv[1],"--defaults-extra-file="))
Options::first_option= argv[1];
}
/* config-file options are prepended to command-line ones */
load_defaults("my", default_groups, &argc, &argv);
if (rc= handle_options(&argc, &argv, my_long_options, get_one_option))
if ((rc= handle_options(&argc, &argv, my_long_options, get_one_option)) != 0)
return rc;
Options::saved_argv= argv;
return 0;

View File

@ -35,6 +35,8 @@ struct Options
static const char *password_file_name;
static const char *default_mysqld_path;
static const char *user;
/* the option which should be passed to process_default_option_files */
static const char *first_option;
static uint monitoring_interval;
static uint port_number;
static const char *bind_address;