Commit dce2554f authored by unknown's avatar unknown
Browse files

Post-review fixes + some bugs fixed + several minor features


BitKeeper/deleted/.del-client_func.c~3476a8a85cbd3c29:
  Delete: server-tools/instance-manager/client_func.c
server-tools/instance-manager/Makefile.am:
  clien_func removed
server-tools/instance-manager/buffer.cc:
  several methods added
server-tools/instance-manager/buffer.h:
  Some error-handling fixes.
server-tools/instance-manager/commands.cc:
  check for Buffer errors
server-tools/instance-manager/guardian.cc:
  Guardian rewiriten. Not it works in a finite state machine-way.
server-tools/instance-manager/guardian.h:
  Appropriate (to .cc) changes in the header + some comment added
server-tools/instance-manager/instance.cc:
  added proxy thread to monitor instance. Two kinds of stop() now -- stop() and kill_instance which
  only sends a signal
server-tools/instance-manager/instance.h:
  appropriate changes
server-tools/instance-manager/instance_map.cc:
  cleanup
server-tools/instance-manager/instance_map.h:
  cleanup
server-tools/instance-manager/instance_options.cc:
  Caching of the pid-file-name is added. some comments added
server-tools/instance-manager/instance_options.h:
  cleanup
server-tools/instance-manager/listener.cc:
  listener my_thread_init added (though it doesn't use any mysys functions). Just in case
server-tools/instance-manager/manager.cc:
  SIGCHLD handler removed. now instance monitoring is implemented through proxy threads. This is to work nicely
  with LinuxThreads
server-tools/instance-manager/options.cc:
  added option to create a password file entry (this was implemented by Sergei Vojtovich)
server-tools/instance-manager/parse.cc:
  inline function get_word moved to the header
server-tools/instance-manager/parse.h:
  get_word moved here to use form parse_output
server-tools/instance-manager/parse_output.cc:
  get_word() clone removed. now looking through the output linewise
server-tools/instance-manager/protocol.cc:
  Buffer error chech added
server-tools/instance-manager/user_map.cc:
  typo fixed
parent 79ba407d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ mysqlmanager_SOURCES= command.cc command.h mysqlmanager.cc \
			buffer.h buffer.cc parse.cc parse.h \
			guardian.cc guardian.h \
			parse_output.cc parse_output.h \
                        mysql_manager_error.h client_func.c
                        mysql_manager_error.h

mysqlmanager_LDADD=	liboptions.a \
			libnet.a \
+14 −2
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@

  RETURN
    0 - ok
    1 - The buffer came to 16Mb barrier
    1 - got an error in reserve()
*/

int Buffer::append(uint position, const char *string, uint len_arg)
@@ -71,7 +71,7 @@ int Buffer::append(uint position, const char *string, uint len_arg)

  RETURN
    0 - ok
    1 - The buffer came to 16Mb barrier
    1 - realloc error or we have come to the 16Mb barrier
*/

int Buffer::reserve(uint position, uint len_arg)
@@ -92,6 +92,18 @@ int Buffer::reserve(uint position, uint len_arg)
  return 0;

err:
  error= 1;
  return 1;
}


int Buffer::get_size()
{
  return buffer_size;
}


int Buffer::is_error()
{
  return error;
}
+11 −3
Original line number Diff line number Diff line
@@ -36,11 +36,17 @@ class Buffer
  /* maximum buffer size is 16Mb */
  enum { MAX_BUFFER_SIZE= 16777216 };
  size_t buffer_size;
  /* Error flag. Triggered if we get an error of some kind */
  int error;
public:
  Buffer()
  Buffer(size_t buffer_size_arg= BUFFER_INITIAL_SIZE)
    :buffer_size(BUFFER_INITIAL_SIZE), error(0)
  {
    buffer=(char *) malloc(BUFFER_INITIAL_SIZE);
    buffer_size= BUFFER_INITIAL_SIZE;
    /*
      As append() will invokes realloc() anyway, it's ok if malloc returns 0
    */
    if (!(buffer= (char*) malloc(buffer_size)))
        buffer_size= 0;
  }

  ~Buffer()
@@ -50,6 +56,8 @@ class Buffer

public:
  char *buffer;
  int get_size();
  int is_error();
  int append(uint position, const char *string, uint len_arg);
  int reserve(uint position, uint len_arg);
};
+0 −32
Original line number Diff line number Diff line
#include <my_global.h>
#include <my_sys.h>
#include <mysql.h>

/*
  Currently we cannot use libmysqlclient directly because of the linking
  issues. Here we provide needed libmysqlclient functions.
  TODO: to think how to use libmysqlclient code instead of copy&paste.
  The other possible solution is to use simple_command directly.
*/

const char * STDCALL
mysql_get_server_info(MYSQL *mysql)
{
  return((char*) mysql->server_version);
}

int STDCALL
mysql_ping(MYSQL *mysql)
{
  DBUG_ENTER("mysql_ping");
  DBUG_RETURN(simple_command(mysql,COM_PING,0,0,0));
}

int STDCALL
mysql_shutdown(MYSQL *mysql, enum mysql_enum_shutdown_level shutdown_level)
{
  uchar level[1];
  DBUG_ENTER("mysql_shutdown");
  level[0]= (uchar) shutdown_level;
  DBUG_RETURN(simple_command(mysql, COM_SHUTDOWN, (char *)level, 1, 0));
}
+8 −4
Original line number Diff line number Diff line
@@ -184,7 +184,8 @@ int Show_instance_status::do_command(struct st_net *net,
    }


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

@@ -270,7 +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))
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
        goto err;
    }

@@ -279,7 +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))
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
        goto err;
    }

@@ -296,7 +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))
      if (my_net_write(net, send_buff.buffer, (uint) position) ||
          send_buff.is_error())
        goto err;
    }
  }
Loading