Commit 34fa3be5 authored by unknown's avatar unknown
Browse files

WL #2713 Change IM behaviour so, that it only reads and alters one config file only.

Implemented on brian's request.


server-tools/instance-manager/Makefile.am:
  define default config file
server-tools/instance-manager/commands.cc:
  Use specified or default file to edit with SET commands instead of hardcoded file
server-tools/instance-manager/commands.h:
  add member to SET commands
server-tools/instance-manager/instance_map.cc:
  rename first_option -> single_defaults_option, made logging a bit more verbose
server-tools/instance-manager/instance_map.h:
  rename first_option -> single_defaults_file + made it public
server-tools/instance-manager/manager.cc:
  rename first_option -> single_defaults_file
server-tools/instance-manager/mysqlmanager.cc:
  goto generic error label instead of simple return
server-tools/instance-manager/options.cc:
  skip --defaults-extra file and give a message if it was specified, made IM
  to read one config file only
server-tools/instance-manager/options.h:
  added new members to the option structure
parent 15413296
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
	-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
	-DDEFAULT_MONITORING_INTERVAL="20" \
	-DDEFAULT_PORT="2273" \
        -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \
	-DPROTOCOL_VERSION=@PROTOCOL_VERSION@

liboptions_a_SOURCES= options.h options.cc priv.h priv.cc
+24 −6
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "mysql_manager_error.h"
#include "protocol.h"
#include "buffer.h"
#include "options.h"

#include <m_string.h>
#include <mysql.h>
@@ -643,6 +644,12 @@ 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) ||
        (option_value_len_arg < MAX_OPTION_LEN - 1))
@@ -689,15 +696,26 @@ int Set_option::correct_file(int skip)
{
  int error;

  error= modify_defaults_file("/etc/my.cnf", option,
  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,
                                option_value, instance_name, skip);
  if (error > 0)

  switch (error)
  {
  case 0:
    return 0;                                   /* everything was fine */
  case 1:
    return ER_OUT_OF_RESOURCES;
  else if (error < 0)
  case 2:
    return ER_ACCESS_OPTION_FILE;
  default:
    DBUG_ASSERT(0);                           /* should never get here */
  }

  /* everything was fine */
  return 0;
  return 0;                                   /* keep compiler happy */
}


+1 −0
Original line number Diff line number Diff line
@@ -187,6 +187,7 @@ class Set_option : public Command
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];
+19 −8
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@

#include "buffer.h"
#include "instance.h"
#include "log.h"
#include "options.h"

#include <m_ctype.h>
#include <mysql_com.h>
@@ -112,8 +114,9 @@ C_MODE_END


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)
                           const char *single_defaults_file_option_arg):
mysqld_path(default_mysqld_path_arg),
single_defaults_file_option(single_defaults_file_option_arg)
{
  pthread_mutex_init(&LOCK_instance_map, 0);
}
@@ -202,7 +205,8 @@ int Instance_map::complete_initialization()
      hash_free should handle it's deletion => goto err, not
      err_instance.
    */
    if (instance->complete_initialization(this, mysqld_path, DEFAULT_SINGLE_INSTANCE))
    if (instance->complete_initialization(this, mysqld_path,
                                          DEFAULT_SINGLE_INSTANCE))
      goto err;
  }
  else
@@ -236,18 +240,25 @@ int Instance_map::load()

  /* the name of the program may be orbitrary here in fact */
  argv_options[0]= "mysqlmanager";
  if (first_option != NULL)
  if (single_defaults_file_option != NULL)
  {
    argc= 2;
    argv_options[1]= first_option;
    argv_options[1]= single_defaults_file_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())
  /*
    If the routine failed, we'll simply fallback to defaults in
    complete_initialization().
  */
  if (my_search_option_files(Options::default_config_file, &argc,
                             (char ***) &argv, &args_used,
                             process_option, (void*) this))
    log_info("Falling back to compiled-in defaults");

  if (complete_initialization())
    return 1;

  return 0;
+2 −2
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class Instance_map
  int init();

  Instance_map(const char *default_mysqld_path_arg,
               const char *first_option_arg);
               const char *single_defaults_file_option_arg);
  ~Instance_map();

  /* loads options from config files */
@@ -77,10 +77,10 @@ class Instance_map

public:
  const char *mysqld_path;
  const char *single_defaults_file_option;
  Guardian_thread *guardian;

private:
  const char *first_option;
  enum { START_HASH_SIZE = 16 };
  pthread_mutex_t LOCK_instance_map;
  HASH hash;
Loading