Commit e2d78b85 authored by unknown's avatar unknown
Browse files

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
parent 31bec292
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -776,9 +776,9 @@ extern void get_defaults_files(int argc, char **argv,
                               char **defaults, char **extra_defaults);
extern int load_defaults(const char *conf_file, const char **groups,
			 int *argc, char ***argv);
extern int process_default_option_files(const char *conf_file,
                                        Process_option_func func,
                                        void *func_ctx);
extern int my_search_option_files(const char *conf_file, int *argc,
                                  char ***argv, uint *args_used,
                                  Process_option_func func, void *func_ctx);
extern void free_defaults(char **argv);
extern void print_defaults(const char *conf_file, const char **groups);
extern my_bool my_compress(byte *, ulong *, ulong *);
+4 −38
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ static char *remove_end_comment(char *ptr);
  Process config files in default directories.

  SYNOPSIS
  search_files()
  my_search_option_files()
  conf_file                   Basename for configuration file to search for.
                              If this is a path, then only this file is read.
  argc                        Pointer to argc of original program
@@ -103,13 +103,13 @@ static char *remove_end_comment(char *ptr);
    1  given cinf_file doesn't exist
*/

static int search_files(const char *conf_file, int *argc, char ***argv,
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
                        uint *args_used, Process_option_func func,
                        void *func_ctx)
{
  const char **dirs, *forced_default_file;
  int error= 0;
  DBUG_ENTER("search_files");
  DBUG_ENTER("my_search_option_files");

  /* Check if we want to force the use a specific default file */
  get_defaults_files(*argc, *argv,
@@ -180,40 +180,6 @@ static int search_files(const char *conf_file, int *argc, char ***argv,
}


/*
  Simplified version of search_files (no argv, argc to process).

  SYNOPSIS
  process_default_option_files()
  conf_file                   Basename for configuration file to search for.
                              If this is a path, then only this file is read.
  func                        Pointer to the function to process options
  func_ctx                    It's context. Usually it is the structure to
                              store additional options.

  DESCRIPTION

  Often we want only to get options from default config files. In this case we
  don't want to provide any argc and argv parameters. This function is a
  simplified variant of search_files which allows us to forget about
  argc, argv.

  RETURN
    0  ok
    1  given cinf_file doesn't exist
*/

int process_default_option_files(const char *conf_file,
                                 Process_option_func func, void *func_ctx)
{
  int argc= 1;
  /* this is a dummy variable for search_files() */
  uint args_used;

  return search_files(conf_file, &argc, NULL, &args_used, func, func_ctx);
}


/*
  The option handler for load_defaults.

@@ -363,7 +329,7 @@ int load_defaults(const char *conf_file, const char **groups,
  ctx.args= &args;
  ctx.group= &group;
  
  error= search_files(conf_file, argc, argv, &args_used,
  error= my_search_option_files(conf_file, argc, argv, &args_used,
                      handle_default_option, (void *) &ctx);
  /*
    Here error contains <> 0 only if we have a fully specified conf_file
+3 −2
Original line number Diff line number Diff line
@@ -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);
}
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ class Instance
  ~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();
+25 −6
Original line number Diff line number Diff line
@@ -110,10 +110,10 @@ static int process_option(void *ctx, const char *group, const char *option)
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 @@ int Instance_map::complete_initialization()

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;

Loading