Commit 4a43ecca authored by unknown's avatar unknown
Browse files

post-review fixes


server-tools/instance-manager/commands.cc:
  remove commented out code
server-tools/instance-manager/instance.cc:
  use flag instead of int variable
server-tools/instance-manager/instance.h:
  no more default values
server-tools/instance-manager/instance_map.cc:
  use flag to be more verbose
server-tools/instance-manager/instance_options.cc:
  don't read options when looking for an option, use strmake instead of strchr
server-tools/instance-manager/instance_options.h:
  fix comment, use flag instead of int value
server-tools/instance-manager/listener.cc:
  don't like c++ comments
server-tools/instance-manager/log.cc:
  safety: strmake adds trailing zero to the string
server-tools/instance-manager/parse_output.cc:
  use strmake instead of strncpy, renamed varianles to make code more readable
server-tools/instance-manager/parse_output.h:
  get rid of default value
parent 26f03563
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -644,10 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg,
    {
      strmake(option, option_arg, option_len_arg);
      strmake(option_value, option_value_arg, option_value_len_arg);
/*    strncpy(option, option_arg, option_len_arg);
      option[option_len_arg]= 0;
      strncpy(option_value, option_value_arg, option_value_len_arg);
      option_value[option_value_len_arg]= 0; */
    }
    else
    {
+2 −2
Original line number Diff line number Diff line
@@ -326,8 +326,8 @@ int Instance::init(const char *name_arg)

int Instance::complete_initialization(Instance_map *instance_map_arg,
                                      const char *mysqld_path,
                                      int only_instance)
                                      uint instance_type)
{
  instance_map= instance_map_arg;
  return options.complete_initialization(mysqld_path, only_instance);
  return options.complete_initialization(mysqld_path, instance_type);
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ class Instance
  ~Instance();
  int init(const char *name);
  int complete_initialization(Instance_map *instance_map_arg,
                              const char *mysqld_path, int only_instance= 0);
                              const char *mysqld_path, uint instance_type);

  bool is_running();
  int start();
+2 −2
Original line number Diff line number Diff line
@@ -202,14 +202,14 @@ int Instance_map::complete_initialization()
      hash_free should handle it's deletion => goto err, not
      err_instance.
    */
    if (instance->complete_initialization(this, mysqld_path, 1))
    if (instance->complete_initialization(this, mysqld_path, DEFAULT_SINGLE_INSTANCE))
      goto err;
  }
  else
    while (i < hash.records)
    {
      instance= (Instance *) hash_element(&hash, i);
      if (instance->complete_initialization(this, mysqld_path))
      if (instance->complete_initialization(this, mysqld_path, USUAL_INSTANCE))
        goto err;
      i++;
    }
+23 −19
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,

  /* +2 eats first "--" from the option string (E.g. "--datadir") */
  rc= parse_output_and_get_value(cmd.buffer, option_name + 2,
                                   result, result_len);
                                 result, result_len, GET_VALUE);

  return rc;
err:
@@ -121,9 +121,8 @@ int Instance_options::get_default_option(char *result, size_t result_len,
int Instance_options::fill_instance_version()
{
  enum { MAX_VERSION_STRING_LENGTH= 160 };
  enum { RETURN_LINE= 1 };
  char result[MAX_VERSION_STRING_LENGTH];
  char version_option[]= " --version";
  char version_option[]= " --no-defaults --version";
  int rc= 1;
  Buffer cmd(mysqld_path_len + sizeof(version_option));

@@ -133,7 +132,7 @@ int Instance_options::fill_instance_version()

  rc= parse_output_and_get_value(cmd.buffer, mysqld_path,
                                 result, MAX_VERSION_STRING_LENGTH,
                                 RETURN_LINE);
                                 GET_LINE);

  if (*result != '\0')
  {
@@ -198,8 +197,8 @@ int Instance_options::fill_log_options()
      goto err;
  }
  else           /* below is safe, as --datadir always has a value */
    strncpy(datadir, strchr(mysqld_datadir, '=') + 1,
            MAX_LOG_OPTION_LENGTH);
    strmake(datadir, strchr(mysqld_datadir, '=') + 1,
            MAX_LOG_OPTION_LENGTH - 1);

  if (gethostname(hostname,sizeof(hostname)-1) < 0)
    strmov(hostname, "mysql");
@@ -232,7 +231,7 @@ int Instance_options::fill_log_options()
          if ((MAX_LOG_OPTION_LENGTH - strlen(full_name)) >
              strlen(log_files->default_suffix))
          {
            strcpy(full_name + strlen(full_name),
            strmov(full_name + strlen(full_name),
                   log_files->default_suffix);
          }
          else
@@ -338,7 +337,7 @@ pid_t Instance_options::get_pid()


int Instance_options::complete_initialization(const char *default_path,
                                              int only_instance)
                                              uint instance_type)
{
  const char *tmp;

@@ -369,18 +368,23 @@ int Instance_options::complete_initialization(const char *default_path,
      found, we would like to model mysqld pid file values.
    */
    if (!gethostname(hostname, sizeof(hostname) - 1))
      (only_instance == 0) ?
    {
      if (instance_type & DEFAULT_SINGLE_INSTANCE)
        strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name, "-",
               hostname, ".pid", NullS):
                 hostname, ".pid", NullS);
      else
        strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", hostname,
                 ".pid", NullS);

    }
    else
      (only_instance == 0) ?
    {
      if (instance_type & DEFAULT_SINGLE_INSTANCE)
        strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name,
               ".pid", NullS):
                 ".pid", NullS);
      else
        strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", "mysql",
                 ".pid", NullS);
    }

    add_option(pidfilename);
  }
Loading