Commit ad1c1e07 authored by unknown's avatar unknown
Browse files

Merge pchardin@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/cps/mysql/devel/im-fix-review


mysys/default.c:
  Auto merged
parents e99c035f d4c2c747
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
+6 −6
Original line number Diff line number Diff line
@@ -30,14 +30,13 @@ liboptions_a_CXXFLAGS= $(CXXFLAGS) \
	-DDEFAULT_LOG_FILE_NAME="$(localstatedir)/mysqlmanager.log" \
	-DDEFAULT_SOCKET_FILE_NAME="$(localstatedir)/mysqlmanager.sock" \
	-DDEFAULT_PASSWORD_FILE_NAME="$(sysconfdir)/mysqlmanager.passwd" \
	-DDEFAULT_MYSQLD_PATH="$(bindir)/mysqld$(EXEEXT)" \
	-DDEFAULT_USER="root" \
	-DDEFAULT_PASSWORD="" \
	-DDEFAULT_MONITORING_INTERVAL="5" \
	-DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \
	-DDEFAULT_MONITORING_INTERVAL="20" \
	-DDEFAULT_PORT="2273" \
	-DPROTOCOL_VERSION=@PROTOCOL_VERSION@

liboptions_a_SOURCES= options.h options.cc priv.h priv.cc
liboptions_a_LIBADD= $(top_builddir)/libmysql/get_password.$(OBJEXT)

# MySQL sometimes uses symlinks to reuse code 
# All symlinked files are grouped in libnet.a
@@ -59,7 +58,7 @@ client_settings.h: Makefile
	rm -f $(srcdir)/client_settings.h
	@LN_CP_F@ $(top_srcdir)/sql/client_settings.h $(srcdir)/client_settings.h

bin_PROGRAMS= mysqlmanager
libexec_PROGRAMS= mysqlmanager

mysqlmanager_SOURCES=	command.cc command.h mysqlmanager.cc \
			manager.h manager.cc log.h log.cc \
@@ -75,7 +74,8 @@ mysqlmanager_SOURCES= command.cc command.h mysqlmanager.cc \
			instance_options.h instance_options.cc \
			buffer.h buffer.cc parse.cc parse.h \
			guardian.cc guardian.h \
                        mysql_manager_error.h client_func.c
			parse_output.cc parse_output.h \
                        mysql_manager_error.h

mysqlmanager_LDADD=	liboptions.a \
			libnet.a \
+20 −8
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)
@@ -81,17 +81,29 @@ 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)));
    if (buffer == NULL)
                                        position + len_arg)), MYF(0));
    if (!(buffer))
      goto err;
    buffer_size= (uint) (buffer_size*1.5);
  }
  return 0;

err:
  error= 1;
  return 1;
}


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


int Buffer::is_error()
{
  return error;
}
+12 −3
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
@@ -36,11 +37,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_size_arg), 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*) my_malloc(buffer_size, MYF(0))))
        buffer_size= 0;
  }

  ~Buffer()
@@ -50,6 +57,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);
};
Loading