Commit 5bd60778 authored by unknown's avatar unknown
Browse files

various fixes


server-tools/instance-manager/buffer.cc:
  use my_realloc instead of realloc
server-tools/instance-manager/buffer.h:
  use my_malloc instead of malloc
server-tools/instance-manager/commands.cc:
  No need to send a buffer if there were some error while writing to it
server-tools/instance-manager/instance_options.cc:
  cleanup
server-tools/instance-manager/manager.cc:
  check sigwait return value
server-tools/instance-manager/parse_output.cc:
  fixed a bug, found with valgrind
parent dce2554f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -81,10 +81,10 @@ int Buffer::reserve(uint position, uint len_arg)

  if (position + len_arg>= buffer_size)
  {
    buffer= (char *) realloc(buffer,
    buffer= (char *) my_realloc(buffer,
                                min(MAX_BUFFER_SIZE,
                                    max((uint) (buffer_size*1.5),
                                     position + len_arg)));
                                        position + len_arg)), MYF(0));
    if (buffer == NULL)
      goto err;
    buffer_size= (uint) (buffer_size*1.5);
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include <my_global.h>
#include <my_sys.h>

#ifdef __GNUC__
#pragma interface
@@ -45,7 +46,7 @@ class Buffer
    /*
      As append() will invokes realloc() anyway, it's ok if malloc returns 0
    */
    if (!(buffer= (char*) malloc(buffer_size)))
    if (!(buffer= (char*) my_malloc(buffer_size, MYF(0))))
        buffer_size= 0;
  }

+8 −8
Original line number Diff line number Diff line
@@ -184,8 +184,8 @@ int Show_instance_status::do_command(struct st_net *net,
    }


    if (my_net_write(net, send_buff.buffer, (uint) position) ||
        send_buff.is_error())
    if (send_buff.is_error() ||
        my_net_write(net, send_buff.buffer, (uint) position))
      goto err;
  }

@@ -271,8 +271,8 @@ int Show_instance_options::do_command(struct st_net *net,
      store_to_string(&send_buff,
                     (char *) instance->options.mysqld_path,
                     &position);
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
      if (send_buff.is_error() ||
          my_net_write(net, send_buff.buffer, (uint) position))
        goto err;
    }

@@ -281,8 +281,8 @@ int Show_instance_options::do_command(struct st_net *net,
      position= 0;
      store_to_string(&send_buff, (char *) "nonguarded", &position);
      store_to_string(&send_buff, "", &position);
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
      if (send_buff.is_error() ||
          my_net_write(net, send_buff.buffer, (uint) position))
        goto err;
    }

@@ -299,8 +299,8 @@ int Show_instance_options::do_command(struct st_net *net,
      store_to_string(&send_buff, option_value + 1, &position);
      /* join name and the value into the same option again */
      *option_value= '=';
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
      if (send_buff.is_error() ||
          my_net_write(net, send_buff.buffer, (uint) position))
        goto err;
    }
  }
+2 −4
Original line number Diff line number Diff line
@@ -80,9 +80,7 @@ void Instance_options::get_pid_filename(char *result)
  char datadir[MAX_PATH_LEN];

  if (mysqld_datadir == NULL)
  {
    get_default_option(datadir, sizeof(datadir), "--datadir");
  }
  else
    strxnmov(datadir, MAX_PATH_LEN - 1, strchr(mysqld_datadir, '=') + 1,
             "/", NullS);
@@ -106,8 +104,8 @@ pid_t Instance_options::get_pid()
  FILE *pid_file_stream;

  /* get the pid */
  if (pid_file_stream= my_fopen(pid_file_with_path,
                                O_RDONLY | O_BINARY, MYF(0)))
  if ((pid_file_stream= my_fopen(pid_file_with_path,
                                O_RDONLY | O_BINARY, MYF(0))) != NULL)
  {
    pid_t pid;

+8 −1
Original line number Diff line number Diff line
@@ -171,7 +171,14 @@ void manager(const Options &options)

  while (!shutdown_complete)
  {
    sigwait(&mask, &signo);
    int status= 0;

    if (status= my_sigwait(&mask, &signo))
    {
      log_error("sigwait() failed");
      goto err;
    }

    switch (signo)
    {
      case THR_SERVER_ALARM:
Loading