Below is the list of changes that have just been committed into a local
5.1 repository of alik. When alik does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-11-21 11:34:09+03:00, anozdrin@stripped +17 -0
Polishing:
- change some return types from int to bool;
- add [ERROR] tag to log_error() output;
- add [INFO] tag to log_info() output;
- change log messages to be more consistent.
server-tools/instance-manager/IMService.cpp@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +7 -7
Log polishing.
server-tools/instance-manager/commands.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +1 -1
Log polishing.
server-tools/instance-manager/commands.h@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +20 -0
Polishing: add default constructors to eliminate warnings.
server-tools/instance-manager/instance.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +4 -5
Log polishing.
server-tools/instance-manager/instance_map.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +12 -12
Log polishing.
server-tools/instance-manager/instance_options.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +48 -37
1) Log polishing.
2) Change int-return type to bool.
server-tools/instance-manager/instance_options.h@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +3 -3
Change int-return type to bool.
server-tools/instance-manager/listener.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +20 -19
Log polishing.
server-tools/instance-manager/log.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +57 -39
Log polishing.
server-tools/instance-manager/log.h@stripped, 2006-11-21 11:34:06+03:00, anozdrin@stripped
+8 -30
Log polishing.
server-tools/instance-manager/manager.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +10 -10
Log polishing.
server-tools/instance-manager/mysql_connection.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +56 -24
Log polishing.
server-tools/instance-manager/mysql_connection.h@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +1 -1
Change int-return type to bool.
server-tools/instance-manager/mysqlmanager.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +2 -1
Log polishing.
server-tools/instance-manager/priv.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +2 -2
Log polishing.
server-tools/instance-manager/thread_registry.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +7 -7
Log polishing.
server-tools/instance-manager/user_map.cc@stripped, 2006-11-21 11:34:06+03:00,
anozdrin@stripped +7 -7
Log polishing.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: anozdrin
# Host: booka.site
# Root: /home/alik/MySQL/devel/5.1-rt-im
--- 1.36/server-tools/instance-manager/listener.cc 2006-11-21 11:34:15 +03:00
+++ 1.37/server-tools/instance-manager/listener.cc 2006-11-21 11:34:15 +03:00
@@ -127,8 +127,8 @@ void Listener::run()
if (rc == 0 || rc == -1)
{
if (rc == -1 && errno != EINTR)
- log_error("Listener: select() failed, %s",
- strerror(errno));
+ log_error("Listener: select() failed: %s.",
+ (const char *) strerror(errno));
continue;
}
@@ -195,8 +195,8 @@ int Listener::create_tcp_socket()
int ip_socket= socket(AF_INET, SOCK_STREAM, 0);
if (ip_socket == INVALID_SOCKET)
{
- log_error("Listener_thead: socket(AF_INET) failed, %s",
- strerror(errno));
+ log_error("Listener: socket(AF_INET) failed: %s.",
+ (const char *) strerror(errno));
return -1;
}
@@ -226,16 +226,16 @@ int Listener::create_tcp_socket()
if (bind(ip_socket, (struct sockaddr *) &ip_socket_address,
sizeof(ip_socket_address)))
{
- log_error("Listener: bind(ip socket) failed, '%s'",
- strerror(errno));
+ log_error("Listener: bind(ip socket) failed: %s.",
+ (const char *) strerror(errno));
close(ip_socket);
return -1;
}
if (listen(ip_socket, LISTEN_BACK_LOG_SIZE))
{
- log_error("Listener: listen(ip socket) failed, %s",
- strerror(errno));
+ log_error("Listener: listen(ip socket) failed: %s.",
+ (const char *) strerror(errno));
close(ip_socket);
return -1;
}
@@ -248,7 +248,8 @@ int Listener::create_tcp_socket()
FD_SET(ip_socket, &read_fds);
sockets[num_sockets++]= ip_socket;
- log_info("accepting connections on ip socket (port: %d)", (int) im_port);
+ log_info("Listener: accepting connections on ip socket (port: %d)...",
+ (int) im_port);
return 0;
}
@@ -259,8 +260,8 @@ create_unix_socket(struct sockaddr_un &u
int unix_socket= socket(AF_UNIX, SOCK_STREAM, 0);
if (unix_socket == INVALID_SOCKET)
{
- log_error("Listener_thead: socket(AF_UNIX) failed, %s",
- strerror(errno));
+ log_error("Listener: socket(AF_UNIX) failed: %s.",
+ (const char *) strerror(errno));
return -1;
}
@@ -279,9 +280,9 @@ create_unix_socket(struct sockaddr_un &u
if (bind(unix_socket, (struct sockaddr *) &unix_socket_address,
sizeof(unix_socket_address)))
{
- log_error("Listener: bind(unix socket) failed, "
- "socket file name is '%s', error '%s'",
- unix_socket_address.sun_path, strerror(errno));
+ log_error("Listener: bind(unix socket) failed for '%s': %s.",
+ (const char *) unix_socket_address.sun_path,
+ (const char *) strerror(errno));
close(unix_socket);
return -1;
}
@@ -290,8 +291,8 @@ create_unix_socket(struct sockaddr_un &u
if (listen(unix_socket, LISTEN_BACK_LOG_SIZE))
{
- log_error("Listener: listen(unix socket) failed, %s",
- strerror(errno));
+ log_error("Listener: listen(unix socket) failed: %s.",
+ (const char *) strerror(errno));
close(unix_socket);
return -1;
}
@@ -302,8 +303,8 @@ create_unix_socket(struct sockaddr_un &u
/* make sure that instances won't be listening our sockets */
set_no_inherit(unix_socket);
- log_info("accepting connections on unix socket '%s'",
- unix_socket_address.sun_path);
+ log_info("Listener: accepting connections on unix socket '%s'...",
+ (const char *) unix_socket_address.sun_path);
sockets[num_sockets++]= unix_socket;
FD_SET(unix_socket, &read_fds);
return 0;
@@ -325,7 +326,7 @@ void Listener::handle_new_mysql_connecti
vio, ++total_connection_count);
if (mysql_connection == NULL || mysql_connection->start(Thread::DETACHED))
{
- log_error("handle_one_mysql_connection() failed");
+ log_error("Listener: can not start connection handler.");
delete mysql_connection;
vio_delete(vio);
}
--- 1.12/server-tools/instance-manager/log.cc 2006-11-21 11:34:15 +03:00
+++ 1.13/server-tools/instance-manager/log.cc 2006-11-21 11:34:15 +03:00
@@ -37,7 +37,8 @@
log()
*/
-static inline void log(FILE *file, const char *format, va_list args)
+static void log(FILE *file,const char *level_tag, const char *format,
+ va_list args)
{
/*
log() should be thread-safe; it implies that we either call fprintf()
@@ -53,15 +54,16 @@ static inline void log(FILE *file, cons
localtime_r(&now, &bd_time);
char buff_date[128];
- sprintf(buff_date, "[%d/%lu] [%02d/%02d/%02d %02d:%02d:%02d] ",
+ sprintf(buff_date, "[%d/%lu] [%02d/%02d/%02d %02d:%02d:%02d] [%s] ",
(int) getpid(),
(unsigned long) pthread_self(),
- bd_time.tm_year % 100,
- bd_time.tm_mon + 1,
- bd_time.tm_mday,
- bd_time.tm_hour,
- bd_time.tm_min,
- bd_time.tm_sec);
+ (int) bd_time.tm_year % 100,
+ (int) bd_time.tm_mon + 1,
+ (int) bd_time.tm_mday,
+ (int) bd_time.tm_hour,
+ (int) bd_time.tm_min,
+ (int) bd_time.tm_sec,
+ (const char *) level_tag);
/* Format the message */
char buff_stack[256];
@@ -109,57 +111,73 @@ static inline void log(FILE *file, cons
/* don't fflush() the file: buffering strategy is set in log_init() */
}
+/**************************************************************************
+ Logging: implementation of public interface.
+**************************************************************************/
-void log_error(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- log(stderr, format, args);
- va_end(args);
-}
+/*
+ The function initializes logging sub-system.
+ SYNOPSIS
+ log_init()
+*/
-void log_info(const char *format, ...)
+void log_init()
{
- va_list args;
- va_start(args, format);
- log(stdout, format, args);
- va_end(args);
+ /*
+ stderr is unbuffered by default; there is no good of line buffering,
+ as all logging is performed linewise - so remove buffering from stdout
+ also
+ */
+ setbuf(stdout, 0);
}
-/* TODO: rewrite with buffering print */
-void print_info(const char *format, ...)
+
+/*
+ The function is intended to log error messages. It precedes a message
+ with date, time and [ERROR] tag and print it to the stderr.
+
+ SYNOPSIS
+ log_error()
+ format [IN] format string
+ ... [IN] arguments to format
+*/
+
+void log_error(const char *format, ...)
{
va_list args;
va_start(args, format);
- vfprintf(stdout, format, args);
+ log(stderr, "ERROR", format, args);
va_end(args);
}
-void print_error(const char *format, ...)
+
+/*
+ The function is intended to log information messages. It precedes
+ a message with date, time and [INFO] tag and print it to the stdout.
+
+ SYNOPSIS
+ log_error()
+ format [IN] format string
+ ... [IN] arguments to format
+*/
+
+void log_info(const char *format, ...)
{
va_list args;
va_start(args, format);
- vfprintf(stderr, format, args);
+ log(stdout, "INFO", format, args);
va_end(args);
}
/*
- log_init()
- RETURN VALUE
- 0 ok
- !0 error
-*/
+ The function prints information to the error log and eixt(1).
-void log_init()
-{
- /*
- stderr is unbuffered by default; there is no good of line buffering,
- as all logging is performed linewise - so remove buffering from stdout
- also
- */
- setbuf(stdout, 0);
-}
+ SYNOPSIS
+ die()
+ format [IN] format string
+ ... [IN] arguments to format
+*/
void die(const char *format, ...)
{
--- 1.4/server-tools/instance-manager/log.h 2006-11-21 11:34:15 +03:00
+++ 1.5/server-tools/instance-manager/log.h 2006-11-21 11:34:15 +03:00
@@ -19,20 +19,23 @@
/*
Logging facilities.
- Two logging streams are supported: error log and info log. Additionally
- libdbug may be used for debug information output.
+ Two logging streams are supported: error log and info log.
+ Additionally libdbug may be used for debug information output.
+
ANSI C buffered I/O is used to perform logging.
+
Logging is performed via stdout/stder, so one can reopen them to point to
- ordinary files. To initialize loggin environment log_init() must be called.
+ ordinary files. To initialize logging environment log_init() must be called.
Rationale:
- no MYSQL_LOG as it has BIN mode, and not easy to fetch from sql_class.h
- no constructors/desctructors to make logging available all the time
- Function names are subject to change.
*/
-/* Precede error message with date and time and print it to the stdout */
+void log_init();
+
+
void log_info(const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format(printf, 1, 2)))
@@ -40,37 +43,12 @@ void log_info(const char *format, ...)
;
-/* Precede error message with date and time and print it to the stderr */
void log_error(const char *format, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 1, 2)))
#endif
;
-
-/*
- Now this is simple catchouts for printf (no date/time is logged), to be
- able to replace underlying streams in future.
-*/
-
-void print_info(const char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 1, 2)))
-#endif
- ;
-
-
-void print_error(const char *format, ...)
-#ifdef __GNUC__
- __attribute__ ((format (printf, 1, 2)))
-#endif
- ;
-
-/* initialize logs */
-void log_init();
-
-
-/* print information to the error log and eixt(1) */
void die(const char *format, ...)
#ifdef __GNUC__
--- 1.42/server-tools/instance-manager/manager.cc 2006-11-21 11:34:15 +03:00
+++ 1.43/server-tools/instance-manager/manager.cc 2006-11-21 11:34:15 +03:00
@@ -191,7 +191,7 @@ int Manager::main()
if (check_if_linux_threads())
{
- log_error("Error: can not check if Linux Threads are used.");
+ log_error("Can not determine thread model.");
return 1;
}
@@ -218,7 +218,7 @@ int Manager::main()
if (instance_map.init())
{
- log_error("Error: can not initialize instance list: out of memory.");
+ log_error("Can not initialize instance list: out of memory.");
return 1;
}
@@ -226,7 +226,7 @@ int Manager::main()
if (user_map.init())
{
- log_error("Error: can not initialize user list: out of memory.");
+ log_error("Can not initialize user list: out of memory.");
return 1;
}
@@ -240,12 +240,12 @@ int Manager::main()
mysqld_safe-compatible mode. Continue, but complain in log.
*/
- log_error("Warning: password file does not exist, "
- "nobody will be able to connect to Instance Manager.");
+ log_info("Warning: password file does not exist, "
+ "nobody will be able to connect to Instance Manager.");
}
else
{
- log_error("Error: %s.", (const char *) err_msg);
+ log_error("%s.", (const char *) err_msg);
return 1;
}
}
@@ -293,7 +293,7 @@ int Manager::main()
*/
if (guardian.start(Thread::DETACHED))
{
- log_error("Error: can not start Guardian thread.");
+ log_error("Can not start Guardian thread.");
goto err;
}
@@ -310,7 +310,7 @@ int Manager::main()
if (flush_instances_status)
{
- log_error("Error: can not init instances repository.");
+ log_error("Can not init instances repository.");
stop_all_threads();
goto err;
}
@@ -320,7 +320,7 @@ int Manager::main()
if (listener.start(Thread::DETACHED))
{
- log_error("Error: can not start Listener thread.");
+ log_error("Can not start Listener thread.");
stop_all_threads();
goto err;
}
@@ -342,7 +342,7 @@ int Manager::main()
if ((status= my_sigwait(&mask, &signo)) != 0)
{
- log_error("Error: sigwait() failed");
+ log_error("sigwait() failed");
stop_all_threads();
goto err;
}
--- 1.22/server-tools/instance-manager/mysqlmanager.cc 2006-11-21 11:34:15 +03:00
+++ 1.23/server-tools/instance-manager/mysqlmanager.cc 2006-11-21 11:34:15 +03:00
@@ -191,7 +191,8 @@ static struct passwd *check_user(const c
return user_info;
err:
- log_error("Fatal error: Can't change to run as user '%s' ; Please check that the user
exists!\n", user);
+ log_error("Can not start under user '%s'.",
+ (const char *) user);
return NULL;
}
--- 1.41/server-tools/instance-manager/commands.cc 2006-11-21 11:34:15 +03:00
+++ 1.42/server-tools/instance-manager/commands.cc 2006-11-21 11:34:15 +03:00
@@ -1539,7 +1539,7 @@ int Set_option::process_option(Instance
if (instance->is_mysqld_compatible() &&
Instance_options::is_option_im_specific(option->get_name()))
{
- log_error("Error: IM-option (%s) can not be used "
+ log_error("IM-option (%s) can not be used "
"in the configuration of mysqld-compatible instance (%s).",
(const char *) option->get_name(),
(const char *) instance->get_name()->str);
--- 1.15/server-tools/instance-manager/commands.h 2006-11-21 11:34:15 +03:00
+++ 1.16/server-tools/instance-manager/commands.h 2006-11-21 11:34:15 +03:00
@@ -38,6 +38,10 @@
class Show_instances: public Command
{
public:
+ Show_instances()
+ { }
+
+public:
int execute(st_net *net, ulong connection_id);
private:
@@ -54,6 +58,10 @@ private:
class Flush_instances: public Command
{
public:
+ Flush_instances()
+ { }
+
+public:
int execute(st_net *net, ulong connection_id);
};
@@ -311,6 +319,10 @@ private:
class Set_option: public Abstract_option_cmd
{
+public:
+ Set_option()
+ { }
+
protected:
virtual bool parse_args(const char **text);
virtual int process_option(Instance *instance, Named_value *option);
@@ -324,6 +336,10 @@ protected:
class Unset_option: public Abstract_option_cmd
{
+public:
+ Unset_option()
+ { }
+
protected:
virtual bool parse_args(const char **text);
virtual int process_option(Instance *instance, Named_value *option);
@@ -341,6 +357,10 @@ protected:
class Syntax_error: public Command
{
+public:
+ Syntax_error()
+ { }
+
public:
int execute(st_net *net, ulong connection_id);
};
--- 1.46/server-tools/instance-manager/instance.cc 2006-11-21 11:34:15 +03:00
+++ 1.47/server-tools/instance-manager/instance.cc 2006-11-21 11:34:15 +03:00
@@ -170,8 +170,8 @@ static bool start_process(Instance_optio
/* exec never returns */
exit(1);
case -1:
- log_info("Instance '%s': can not start mysqld: fork() failed.",
- (const char *) instance_options->instance_name.str);
+ log_error("Instance '%s': can not start mysqld: fork() failed.",
+ (const char *) instance_options->instance_name.str);
return TRUE;
}
@@ -699,10 +699,9 @@ void Instance::kill_mysqld(int signum)
/* Kill suceeded */
if (signum == SIGKILL) /* really killed instance with SIGKILL */
{
- log_error("The instance '%s' is being stopped forcibly. Normally"
- "it should not happen. Probably the instance has been"
- "hanging. You should also check your IM setup",
+ log_error("Instance '%s': killed.",
(const char *) options.instance_name.str);
+
/* After sucessful hard kill the pidfile need to be removed */
options.unlink_pidfile();
}
--- 1.33/server-tools/instance-manager/instance_map.cc 2006-11-21 11:34:15 +03:00
+++ 1.34/server-tools/instance-manager/instance_map.cc 2006-11-21 11:34:15 +03:00
@@ -336,14 +336,14 @@ int Instance_map::create_instance(const
if (!instance)
{
- log_error("Error: can not allocate instance (name: '%s').",
+ log_error("Can not allocate instance (name: '%s').",
(const char *) instance_name->str);
return ER_OUT_OF_RESOURCES;
}
if (instance->init(instance_name))
{
- log_error("Error: can not initialize instance (name: '%s').",
+ log_error("Can not initialize instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
@@ -356,7 +356,7 @@ int Instance_map::create_instance(const
if (instance->is_mysqld_compatible() &&
Instance_options::is_option_im_specific(option.get_name()))
{
- log_error("Error: IM-option (%s) can not be used "
+ log_error("IM-option (%s) can not be used "
"in configuration of mysqld-compatible instance (%s).",
(const char *) option.get_name(),
(const char *) instance_name->str);
@@ -373,7 +373,7 @@ int Instance_map::create_instance(const
if (instance->complete_initialization())
{
- log_error("Error: can not complete initialization of instance (name: '%s').",
+ log_error("Can not complete initialization of instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
@@ -382,7 +382,7 @@ int Instance_map::create_instance(const
if (add_instance(instance))
{
- log_error("Error: can not register instance (name: '%s').",
+ log_error("Can not register instance (name: '%s').",
(const char *) instance_name->str);
delete instance;
return ER_OUT_OF_RESOURCES;
@@ -426,7 +426,7 @@ bool Instance_map::complete_initializati
if (create_instance(&Instance::DFLT_INSTANCE_NAME, NULL))
{
- log_error("Error: could not create default instance.");
+ log_error("Can not create default instance.");
return TRUE;
}
@@ -441,7 +441,7 @@ bool Instance_map::complete_initializati
break;
default:
- log_error("Error: could not add default instance to the config file.");
+ log_error("Can not add default instance to the config file.");
Instance *instance= find(&Instance::DFLT_INSTANCE_NAME);
@@ -499,7 +499,7 @@ int Instance_map::load()
if (my_search_option_files(Options::Main::config_file, &argc,
(char ***) &argv, &args_used,
process_option, (void*) this))
- log_info("Falling back to compiled-in defaults");
+ log_info("Falling back to compiled-in defaults.");
return complete_initialization();
}
@@ -566,7 +566,7 @@ int create_instance_in_file(const LEX_ST
if (my_access(Options::Main::config_file, W_OK))
{
- log_error("Error: configuration file (%s) does not exist.",
+ log_error("Configuration file (%s) does not exist.",
(const char *) Options::Main::config_file);
return ER_CONF_FILE_DOES_NOT_EXIST;
}
@@ -575,7 +575,7 @@ int create_instance_in_file(const LEX_ST
if (cnf_file <= 0)
{
- log_error("Error: can not open configuration file (%s): %s.",
+ log_error("Can not open configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
return ER_ACCESS_OPTION_FILE;
@@ -588,7 +588,7 @@ int create_instance_in_file(const LEX_ST
my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
- log_error("Error: can not write to configuration file (%s): %s.",
+ log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
my_close(cnf_file, MYF(0));
@@ -612,7 +612,7 @@ int create_instance_in_file(const LEX_ST
if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
- log_error("Error: can not write to configuration file (%s): %s.",
+ log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,
(const char *) strerror(errno));
my_close(cnf_file, MYF(0));
--- 1.39/server-tools/instance-manager/instance_options.cc 2006-11-21 11:34:15 +03:00
+++ 1.40/server-tools/instance-manager/instance_options.cc 2006-11-21 11:34:15 +03:00
@@ -36,7 +36,7 @@
/* Create "mysqld ..." command in the buffer */
-static inline int create_mysqld_command(Buffer *buf,
+static inline bool create_mysqld_command(Buffer *buf,
const LEX_STRING *mysqld_path,
const LEX_STRING *option)
{
@@ -55,9 +55,9 @@ static inline int create_mysqld_command(
/* here the '\0' character is copied from the option string */
buf->append(position, option->str, option->length + 1);
- return buf->is_error();
+ return buf->is_error() ? TRUE : FALSE;
}
- return 1;
+ return TRUE;
}
@@ -152,27 +152,36 @@ err:
Get mysqld version string from "mysqld --version" output.
RETURN
- 0 - ok
- 1 - error occured
+ FALSE - ok
+ TRUE - error occured
*/
-int Instance_options::fill_instance_version()
+bool Instance_options::fill_instance_version()
{
char result[MAX_VERSION_LENGTH];
LEX_STRING version_option=
{ C_STRING_WITH_LEN(" --no-defaults --version") };
- int rc= 1;
Buffer cmd(mysqld_path.length + version_option.length + 1);
if (create_mysqld_command(&cmd, &mysqld_path, &version_option))
- goto err;
+ {
+ log_error("Failed to get version of '%s': out of memory.",
+ (const char *) mysqld_path.str);
+ return TRUE;
+ }
bzero(result, MAX_VERSION_LENGTH);
- rc= parse_output_and_get_value(cmd.buffer, "Ver", result,
- MAX_VERSION_LENGTH, GET_LINE);
+ if (parse_output_and_get_value(cmd.buffer, "Ver", result,
+ MAX_VERSION_LENGTH, GET_LINE))
+ {
+ log_error("Failed to get version of '%s': unexpected output.",
+ (const char *) mysqld_path.str);
+ return TRUE;
+ }
+
+ DBUG_ASSERT(*result != '\0');
- if (*result != '\0')
{
char *start;
/* chop the newline from the end of the version string */
@@ -184,11 +193,8 @@ int Instance_options::fill_instance_vers
mysqld_version= strdup_root(&alloc, start);
}
-err:
- if (rc)
- log_error("fill_instance_version: Failed to get version of '%s'",
- (const char *) mysqld_path.str);
- return rc;
+
+ return FALSE;
}
@@ -207,28 +213,37 @@ err:
script(for example libtool) or a symlink.
RETURN
- 0 - ok
- 1 - error occured
+ FALSE - ok
+ TRUE - error occured
*/
-int Instance_options::fill_mysqld_real_path()
+bool Instance_options::fill_mysqld_real_path()
{
char result[FN_REFLEN];
LEX_STRING help_option=
{ C_STRING_WITH_LEN(" --no-defaults --help") };
- int rc= 1;
Buffer cmd(mysqld_path.length + help_option.length);
if (create_mysqld_command(&cmd, &mysqld_path, &help_option))
- goto err;
+ {
+ log_error("Failed to get real path of '%s': out of memory.",
+ (const char *) mysqld_path.str);
+ return TRUE;
+ }
bzero(result, FN_REFLEN);
- rc= parse_output_and_get_value(cmd.buffer, "Usage: ",
+ if (parse_output_and_get_value(cmd.buffer, "Usage: ",
result, FN_REFLEN,
- GET_LINE);
+ GET_LINE))
+ {
+ log_error("Failed to get real path of '%s': unexpected output.",
+ (const char *) mysqld_path.str);
+ return TRUE;
+ }
+
+ DBUG_ASSERT(*result != '\0');
- if (*result != '\0')
{
char* options_str;
/* chop the path of at [OPTIONS] */
@@ -237,10 +252,8 @@ int Instance_options::fill_mysqld_real_p
mysqld_real_path.str= strdup_root(&alloc, result);
mysqld_real_path.length= strlen(mysqld_real_path.str);
}
-err:
- if (rc)
- log_error("fill_mysqld_real_path: Failed to get real path of mysqld");
- return rc;
+
+ return FALSE;
}
@@ -257,11 +270,11 @@ err:
file name and placement.
RETURN
- 0 - ok
- 1 - error occured
+ FALSE - ok
+ TRUE - error occured
*/
-int Instance_options::fill_log_options()
+bool Instance_options::fill_log_options()
{
Buffer buff;
enum { MAX_LOG_OPTION_LENGTH= 256 };
@@ -287,7 +300,7 @@ int Instance_options::fill_log_options()
if (mysqld_datadir == NULL)
{
if (get_default_option(datadir, MAX_LOG_OPTION_LENGTH, "--datadir"))
- goto err;
+ return TRUE;
}
else
{
@@ -325,7 +338,7 @@ int Instance_options::fill_log_options()
if ((MAX_LOG_OPTION_LENGTH - strlen(full_name)) <=
strlen(log_files->default_suffix))
- goto err;
+ return TRUE;
strmov(full_name + strlen(full_name), log_files->default_suffix);
@@ -345,15 +358,13 @@ int Instance_options::fill_log_options()
datadir, "", MY_UNPACK_FILENAME | MY_SAFE_PATH);
if (!(*(log_files->value)= strdup_root(&alloc, full_name)))
- goto err;
+ return TRUE;
}
}
}
}
- return 0;
-err:
- return 1;
+ return FALSE;
}
--- 1.21/server-tools/instance-manager/instance_options.h 2006-11-21 11:34:15 +03:00
+++ 1.22/server-tools/instance-manager/instance_options.h 2006-11-21 11:34:15 +03:00
@@ -91,9 +91,9 @@ public:
char *logs[3];
private:
- int fill_log_options();
- int fill_instance_version();
- int fill_mysqld_real_path();
+ bool fill_log_options();
+ bool fill_instance_version();
+ bool fill_mysqld_real_path();
int add_to_argv(const char *option);
int get_default_option(char *result, size_t result_len,
const char *option_name);
--- 1.21/server-tools/instance-manager/mysql_connection.cc 2006-11-21 11:34:15 +03:00
+++ 1.22/server-tools/instance-manager/mysql_connection.cc 2006-11-21 11:34:15 +03:00
@@ -77,24 +77,30 @@ C_MODE_END
This function is complementary to cleanup().
*/
-int Mysql_connection::init()
+bool Mysql_connection::init()
{
/* Allocate buffers for network I/O */
if (my_net_init(&net, vio))
- return 1;
+ return TRUE;
+
net.return_status= &status;
+
/* Initialize random number generator */
{
ulong seed1= (ulong) &rand_st + rand();
ulong seed2= (ulong) rand() + time(0);
randominit(&rand_st, seed1, seed2);
}
+
/* Fill scramble - server's random message used for handshake */
create_random_string(scramble, SCRAMBLE_LENGTH, &rand_st);
+
/* We don't support transactions, every query is atomic */
status= SERVER_STATUS_AUTOCOMMIT;
+
thread_registry->register_thread(&thread_info);
- return 0;
+
+ return FALSE;
}
@@ -114,12 +120,17 @@ Mysql_connection::~Mysql_connection()
void Mysql_connection::main()
{
- log_info("accepted mysql connection %lu", (unsigned long) connection_id);
+ log_info("Connection %lu: accepted.", (unsigned long) connection_id);
if (check_connection())
+ {
+ log_info("Connection %lu: failed to authorize the user.",
+ (unsigned long) connection_id);
+
return;
+ }
- log_info("connection %lu is checked successfully",
+ log_info("Connection %lu: the user was authorized successfully.",
(unsigned long) connection_id);
vio_keepalive(vio, TRUE);
@@ -257,8 +268,11 @@ int Mysql_connection::do_command()
packet= (char*) net.read_pos;
enum enum_server_command command= (enum enum_server_command)
(uchar) *packet;
- log_info("connection %d: packet_length=%d, command=%d",
- (int) connection_id, (int) packet_length, (int) command);
+ log_info("Connection %lu: received packet (length: %lu; command: %d).",
+ (unsigned long) connection_id,
+ (unsigned long) packet_length,
+ (int) command);
+
return dispatch_command(command, packet + 1);
}
}
@@ -268,63 +282,81 @@ int Mysql_connection::dispatch_command(e
{
switch (command) {
case COM_QUIT: // client exit
- log_info("query for connection %lu received quit command",
+ log_info("Connection %lu: received QUIT command.",
(unsigned long) connection_id);
return 1;
+
case COM_PING:
- log_info("query for connection %lu received ping command",
+ log_info("Connection %lu: received PING command.",
(unsigned long) connection_id);
net_send_ok(&net, connection_id, NULL);
- break;
+ return 0;
+
case COM_QUERY:
{
- log_info("query for connection %d : ----\n%s\n-------------------------",
- (int) connection_id,
+ log_info("Connection %lu: received QUERY command: '%s'.",
+ (unsigned long) connection_id,
(const char *) packet);
+
if (Command *command= parse_command(packet))
{
int res= 0;
- log_info("query for connection %lu successfully parsed",
+
+ log_info("Connection %lu: query parsed successfully.",
(unsigned long) connection_id);
+
res= command->execute(&net, connection_id);
delete command;
+
if (!res)
- log_info("query for connection %lu executed ok",
+ {
+ log_info("Connection %lu: query executed successfully",
(unsigned long) connection_id);
+ }
else
{
- log_info("query for connection %lu executed err=%d",
- (unsigned long) connection_id, (int) res);
+ log_info("Connection %lu: can not execute query (error: %d).",
+ (unsigned long) connection_id,
+ (int) res);
+
net_send_error(&net, res);
- return 0;
}
}
else
{
+ log_error("Connection %lu: can not parse query: out ot resources.",
+ (unsigned long) connection_id);
+
net_send_error(&net,ER_OUT_OF_RESOURCES);
- return 0;
}
- break;
+
+ return 0;
}
+
default:
- log_info("query for connection %lu received unknown command",
- (unsigned long) connection_id);
+ log_info("Connection %lu: received unsupported command (%d).",
+ (unsigned long) connection_id,
+ (int) command);
+
net_send_error(&net, ER_UNKNOWN_COM_ERROR);
- break;
+ return 0;
}
- return 0;
+
+ return 0; /* Just to make compiler happy. */
}
void Mysql_connection::run()
{
if (init())
- log_info("Mysql_connection::run(): error initializing thread");
+ log_error("Connection %lu: can not init handler.",
+ (unsigned long) connection_id);
else
{
main();
cleanup();
}
+
delete this;
}
--- 1.7/server-tools/instance-manager/mysql_connection.h 2006-11-21 11:34:15 +03:00
+++ 1.8/server-tools/instance-manager/mysql_connection.h 2006-11-21 11:34:15 +03:00
@@ -61,7 +61,7 @@ private:
ulong client_capabilities;
private:
/* The main loop implementation triad */
- int init();
+ bool init();
void main();
void cleanup();
--- 1.16/server-tools/instance-manager/priv.cc 2006-11-21 11:34:15 +03:00
+++ 1.17/server-tools/instance-manager/priv.cc 2006-11-21 11:34:15 +03:00
@@ -55,7 +55,7 @@ int create_pid_file(const char *pid_file
if (!(pid_file= my_fopen(pid_file_name, O_WRONLY | O_CREAT | O_BINARY,
MYF(0))))
{
- log_error("Error: can not create pid file '%s': %s (errno: %d)",
+ log_error("Can not create pid file '%s': %s (errno: %d)",
(const char *) pid_file_name,
(const char *) strerror(errno),
(int) errno);
@@ -64,7 +64,7 @@ int create_pid_file(const char *pid_file
if (fprintf(pid_file, "%d\n", (int) pid) <= 0)
{
- log_error("Error: can not write to pid file '%s': %s (errno: %d)",
+ log_error("Can not write to pid file '%s': %s (errno: %d)",
(const char *) pid_file_name,
(const char *) strerror(errno),
(int) errno);
--- 1.15/server-tools/instance-manager/thread_registry.cc 2006-11-21 11:34:15 +03:00
+++ 1.16/server-tools/instance-manager/thread_registry.cc 2006-11-21 11:34:15 +03:00
@@ -87,11 +87,11 @@ Thread_registry::~Thread_registry()
void Thread_registry::register_thread(Thread_info *info,
bool send_signal_on_shutdown)
{
- log_info("Thread_registry: registering thread %d...",
- (int) info->thread_id);
-
info->init(send_signal_on_shutdown);
+ log_info("Thread_registry: registering thread %lu...",
+ (unsigned long) info->thread_id);
+
#ifndef __WIN__
struct sigaction sa;
sa.sa_handler= handle_signal;
@@ -118,8 +118,8 @@ void Thread_registry::register_thread(Th
void Thread_registry::unregister_thread(Thread_info *info)
{
- log_info("Thread_registry: unregistering thread %d...",
- (int) info->thread_id);
+ log_info("Thread_registry: unregistering thread %lu...",
+ (unsigned long) info->thread_id);
pthread_mutex_lock(&LOCK_thread_registry);
info->prev->next= info->next;
@@ -395,13 +395,13 @@ bool Thread::join()
{
if (!id)
{
- log_error("Error: thread has not been started.");
+ log_error("Thread has not been started.");
return TRUE;
}
if (detached)
{
- log_error("Error: can not join detached thread %lu.",
+ log_error("Can not join detached thread %lu.",
(unsigned long) id);
return TRUE;
}
--- 1.21/server-tools/instance-manager/user_map.cc 2006-11-21 11:34:15 +03:00
+++ 1.22/server-tools/instance-manager/user_map.cc 2006-11-21 11:34:15 +03:00
@@ -41,7 +41,7 @@ int User::init(const char *line)
name_end= strchr(name_begin, line[0]);
if (name_end == 0 || name_end[1] != ':')
{
- log_info("Error: invalid format (unmatched quote) of user line (%s).",
+ log_error("Invalid format (unmatched quote) of user line (%s).",
(const char *) line);
return 1;
}
@@ -53,7 +53,7 @@ int User::init(const char *line)
name_end= strchr(name_begin, ':');
if (name_end == 0)
{
- log_info("Error: invalid format (no delimiter) of user line (%s).",
+ log_error("Invalid format (no delimiter) of user line (%s).",
(const char *) line);
return 1;
}
@@ -63,7 +63,7 @@ int User::init(const char *line)
user_length= name_end - name_begin;
if (user_length > USERNAME_LENGTH)
{
- log_info("Error: user name is too long (%d). Max length: %d. "
+ log_error("User name is too long (%d). Max length: %d. "
"User line: '%s'.",
(int) user_length,
(int) USERNAME_LENGTH,
@@ -74,7 +74,7 @@ int User::init(const char *line)
password_length= strlen(password);
if (password_length > SCRAMBLED_PASSWORD_CHAR_LENGTH)
{
- log_info("Error: password is too long (%d). Max length: %d."
+ log_error("Password is too long (%d). Max length: %d."
"User line: '%s'.",
(int) password_length,
(int) SCRAMBLED_PASSWORD_CHAR_LENGTH,
@@ -90,7 +90,7 @@ int User::init(const char *line)
get_salt_from_password(salt, password);
- log_info("loaded user '%s'.", user);
+ log_info("Loaded user '%s'.", (const char *) user);
return 0;
}
@@ -214,7 +214,7 @@ int User_map::load(const char *password_
return ERR_IO_ERROR;
}
- log_info("loading the password database...");
+ log_info("Loading the password database...");
while (fgets(line, sizeof(line), file))
{
@@ -292,7 +292,7 @@ int User_map::load(const char *password_
}
}
- log_info("the password database loaded successfully.");
+ log_info("The password database loaded successfully.");
my_fclose(file, MYF(0));
--- 1.10/server-tools/instance-manager/IMService.cpp 2006-11-21 11:34:15 +03:00
+++ 1.11/server-tools/instance-manager/IMService.cpp 2006-11-21 11:34:15 +03:00
@@ -54,24 +54,24 @@ int HandleServiceOptions()
if (Options::Service::install_as_service)
{
if (winService.IsInstalled())
- log_info("Service is already installed");
+ log_info("Service is already installed.");
else if (winService.Install())
- log_info("Service installed successfully");
+ log_info("Service installed successfully.");
else
{
- log_info("Service failed to install");
+ log_error("Service failed to install.");
ret_val= 1;
}
}
else if (Options::Service::remove_service)
{
if (! winService.IsInstalled())
- log_info("Service is not installed");
+ log_info("Service is not installed.");
else if (winService.Remove())
- log_info("Service removed successfully");
+ log_info("Service removed successfully.");
else
{
- log_info("Service failed to remove");
+ log_error("Service failed to remove.");
ret_val= 1;
}
}
@@ -81,7 +81,7 @@ int HandleServiceOptions()
if (!winService.Init())
{
- log_info("Service failed to initialize.");
+ log_error("Service failed to initialize.");
fprintf(stderr,
"The service should be started by Windows Service Manager.\n"
"The MySQL Manager should be started with '--standalone'\n"
| Thread |
|---|
| • bk commit into 5.1 tree (anozdrin:1.2375) | Alexander Nozdrin | 21 Nov |