Commit 7d55b07f authored by thek@adventure.(none)'s avatar thek@adventure.(none)

Bug#28012 Patch : IM crashes instead of reporting an error when mysqldpath is bad

  
On the windows platform, if an instance object failed to initialize during
program start, the instance manager would crash.
This could happen if an incorrect mysqld path was supplied in the 
defaults configuration file.
The patch prevents the program from crashing and makes it show an
error message instead.
parent 08e7d2d3
......@@ -37,9 +37,10 @@ log-slow-queries option_value
language option_value
character-sets-dir option_value
basedir option_value
shutdown-delay option_value
skip-stack-trace option_value
skip-innodb option_value
skip-ndbcluster option_value
loose-skip-innodb option_value
loose-skip-ndbcluster option_value
nonguarded option_value
log-output option_value
SET mysqld2.server_id = 2;
......@@ -57,9 +58,10 @@ log-slow-queries option_value
language option_value
character-sets-dir option_value
basedir option_value
shutdown-delay option_value
skip-stack-trace option_value
skip-innodb option_value
skip-ndbcluster option_value
loose-skip-innodb option_value
loose-skip-ndbcluster option_value
nonguarded option_value
log-output option_value
server_id option_value
......
......@@ -524,24 +524,17 @@ bool Instance::init(const LEX_STRING *name_arg)
/**
Complete instance options initialization.
@brief Complete instance options initialization.
SYNOPSIS
complete_initialization()
RETURN
FALSE - ok
TRUE - error
@return Error status.
@retval FALSE ok
@retval TRUE error
*/
bool Instance::complete_initialization()
{
configured= ! options.complete_initialization();
return FALSE;
/*
TODO: return actual status (from
Instance_options::complete_initialization()) here.
*/
return !configured;
}
/**************************************************************************
......@@ -644,25 +637,24 @@ bool Instance::is_mysqld_running()
/**
Start mysqld.
@brief Start mysqld.
SYNOPSIS
start_mysqld()
DESCRIPTION
Reset flags and start Instance Monitor thread, which will start mysqld.
Reset flags and start Instance Monitor thread, which will start mysqld.
MT-NOTE: instance must be locked before calling the operation.
@note Instance must be locked before calling the operation.
RETURN
FALSE - ok
TRUE - could not start instance
@return Error status code
@retval FALSE Ok
@retval TRUE Could not start instance
*/
bool Instance::start_mysqld()
{
Instance_monitor *instance_monitor;
if (!configured)
return TRUE;
/*
Prepare instance to start Instance Monitor thread.
......
......@@ -156,7 +156,8 @@ int Instance_options::get_default_option(char *result, size_t result_len,
goto err;
/* +2 eats first "--" from the option string (E.g. "--datadir") */
rc= parse_output_and_get_value((char*) cmd.buffer, option_name + 2,
rc= parse_output_and_get_value((char*) cmd.buffer,
option_name + 2, strlen(option_name + 2),
result, result_len, GET_VALUE);
err:
return rc;
......@@ -194,8 +195,8 @@ bool Instance_options::fill_instance_version()
bzero(result, MAX_VERSION_LENGTH);
if (parse_output_and_get_value((char*) cmd.buffer, "Ver", result,
MAX_VERSION_LENGTH, GET_LINE))
if (parse_output_and_get_value((char*) cmd.buffer, STRING_WITH_LEN("Ver"),
result, MAX_VERSION_LENGTH, GET_LINE))
{
log_error("Failed to get version of '%s': unexpected output.",
(const char *) mysqld_path.str);
......@@ -206,8 +207,7 @@ bool Instance_options::fill_instance_version()
{
char *start;
/* chop the newline from the end of the version string */
result[strlen(result) - NEWLINE_LEN]= '\0';
/* trim leading whitespaces */
start= result;
while (my_isspace(default_charset_info, *start))
......@@ -255,7 +255,8 @@ bool Instance_options::fill_mysqld_real_path()
bzero(result, FN_REFLEN);
if (parse_output_and_get_value((char*) cmd.buffer, "Usage: ",
if (parse_output_and_get_value((char*) cmd.buffer,
STRING_WITH_LEN("Usage: "),
result, FN_REFLEN,
GET_LINE))
{
......
......@@ -17,11 +17,17 @@
#include <my_global.h>
#define GET_VALUE 1
#define GET_LINE 2
enum enum_option_type
{
GET_VALUE = 1,
GET_LINE
};
int parse_output_and_get_value(const char *command, const char *word,
char *result, size_t input_buffer_len,
uint flag);
bool parse_output_and_get_value(const char *command,
const char *option_name_str,
uint option_name_length,
char *option_value_buf,
size_t option_value_buf_size,
enum_option_type option_type);
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
......@@ -48,11 +48,16 @@ typedef int pid_t;
#define NEWLINE "\r\n"
#define NEWLINE_LEN 2
const char CR = '\r';
const char LF = '\n';
#else /* ! __WIN__ */
#define NEWLINE "\n"
#define NEWLINE_LEN 1
const char LF = '\n';
#endif /* __WIN__ */
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PORTABILITY_H */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment