mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
post-review fixes
This commit is contained in:
@ -644,10 +644,6 @@ Set_option::Set_option(Instance_map *instance_map_arg,
|
|||||||
{
|
{
|
||||||
strmake(option, option_arg, option_len_arg);
|
strmake(option, option_arg, option_len_arg);
|
||||||
strmake(option_value, option_value_arg, option_value_len_arg);
|
strmake(option_value, option_value_arg, option_value_len_arg);
|
||||||
/* strncpy(option, option_arg, option_len_arg);
|
|
||||||
option[option_len_arg]= 0;
|
|
||||||
strncpy(option_value, option_value_arg, option_value_len_arg);
|
|
||||||
option_value[option_value_len_arg]= 0; */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -326,8 +326,8 @@ int Instance::init(const char *name_arg)
|
|||||||
|
|
||||||
int Instance::complete_initialization(Instance_map *instance_map_arg,
|
int Instance::complete_initialization(Instance_map *instance_map_arg,
|
||||||
const char *mysqld_path,
|
const char *mysqld_path,
|
||||||
int only_instance)
|
uint instance_type)
|
||||||
{
|
{
|
||||||
instance_map= instance_map_arg;
|
instance_map= instance_map_arg;
|
||||||
return options.complete_initialization(mysqld_path, only_instance);
|
return options.complete_initialization(mysqld_path, instance_type);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
~Instance();
|
~Instance();
|
||||||
int init(const char *name);
|
int init(const char *name);
|
||||||
int complete_initialization(Instance_map *instance_map_arg,
|
int complete_initialization(Instance_map *instance_map_arg,
|
||||||
const char *mysqld_path, int only_instance= 0);
|
const char *mysqld_path, uint instance_type);
|
||||||
|
|
||||||
bool is_running();
|
bool is_running();
|
||||||
int start();
|
int start();
|
||||||
|
@ -202,14 +202,14 @@ int Instance_map::complete_initialization()
|
|||||||
hash_free should handle it's deletion => goto err, not
|
hash_free should handle it's deletion => goto err, not
|
||||||
err_instance.
|
err_instance.
|
||||||
*/
|
*/
|
||||||
if (instance->complete_initialization(this, mysqld_path, 1))
|
if (instance->complete_initialization(this, mysqld_path, DEFAULT_SINGLE_INSTANCE))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
while (i < hash.records)
|
while (i < hash.records)
|
||||||
{
|
{
|
||||||
instance= (Instance *) hash_element(&hash, i);
|
instance= (Instance *) hash_element(&hash, i);
|
||||||
if (instance->complete_initialization(this, mysqld_path))
|
if (instance->complete_initialization(this, mysqld_path, USUAL_INSTANCE))
|
||||||
goto err;
|
goto err;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,
|
|||||||
|
|
||||||
/* +2 eats first "--" from the option string (E.g. "--datadir") */
|
/* +2 eats first "--" from the option string (E.g. "--datadir") */
|
||||||
rc= parse_output_and_get_value(cmd.buffer, option_name + 2,
|
rc= parse_output_and_get_value(cmd.buffer, option_name + 2,
|
||||||
result, result_len);
|
result, result_len, GET_VALUE);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
err:
|
err:
|
||||||
@ -121,9 +121,8 @@ err:
|
|||||||
int Instance_options::fill_instance_version()
|
int Instance_options::fill_instance_version()
|
||||||
{
|
{
|
||||||
enum { MAX_VERSION_STRING_LENGTH= 160 };
|
enum { MAX_VERSION_STRING_LENGTH= 160 };
|
||||||
enum { RETURN_LINE= 1 };
|
|
||||||
char result[MAX_VERSION_STRING_LENGTH];
|
char result[MAX_VERSION_STRING_LENGTH];
|
||||||
char version_option[]= " --version";
|
char version_option[]= " --no-defaults --version";
|
||||||
int rc= 1;
|
int rc= 1;
|
||||||
Buffer cmd(mysqld_path_len + sizeof(version_option));
|
Buffer cmd(mysqld_path_len + sizeof(version_option));
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ int Instance_options::fill_instance_version()
|
|||||||
|
|
||||||
rc= parse_output_and_get_value(cmd.buffer, mysqld_path,
|
rc= parse_output_and_get_value(cmd.buffer, mysqld_path,
|
||||||
result, MAX_VERSION_STRING_LENGTH,
|
result, MAX_VERSION_STRING_LENGTH,
|
||||||
RETURN_LINE);
|
GET_LINE);
|
||||||
|
|
||||||
if (*result != '\0')
|
if (*result != '\0')
|
||||||
{
|
{
|
||||||
@ -198,8 +197,8 @@ int Instance_options::fill_log_options()
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
else /* below is safe, as --datadir always has a value */
|
else /* below is safe, as --datadir always has a value */
|
||||||
strncpy(datadir, strchr(mysqld_datadir, '=') + 1,
|
strmake(datadir, strchr(mysqld_datadir, '=') + 1,
|
||||||
MAX_LOG_OPTION_LENGTH);
|
MAX_LOG_OPTION_LENGTH - 1);
|
||||||
|
|
||||||
if (gethostname(hostname,sizeof(hostname)-1) < 0)
|
if (gethostname(hostname,sizeof(hostname)-1) < 0)
|
||||||
strmov(hostname, "mysql");
|
strmov(hostname, "mysql");
|
||||||
@ -232,7 +231,7 @@ int Instance_options::fill_log_options()
|
|||||||
if ((MAX_LOG_OPTION_LENGTH - strlen(full_name)) >
|
if ((MAX_LOG_OPTION_LENGTH - strlen(full_name)) >
|
||||||
strlen(log_files->default_suffix))
|
strlen(log_files->default_suffix))
|
||||||
{
|
{
|
||||||
strcpy(full_name + strlen(full_name),
|
strmov(full_name + strlen(full_name),
|
||||||
log_files->default_suffix);
|
log_files->default_suffix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -338,7 +337,7 @@ pid_t Instance_options::get_pid()
|
|||||||
|
|
||||||
|
|
||||||
int Instance_options::complete_initialization(const char *default_path,
|
int Instance_options::complete_initialization(const char *default_path,
|
||||||
int only_instance)
|
uint instance_type)
|
||||||
{
|
{
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
@ -369,18 +368,23 @@ int Instance_options::complete_initialization(const char *default_path,
|
|||||||
found, we would like to model mysqld pid file values.
|
found, we would like to model mysqld pid file values.
|
||||||
*/
|
*/
|
||||||
if (!gethostname(hostname, sizeof(hostname) - 1))
|
if (!gethostname(hostname, sizeof(hostname) - 1))
|
||||||
(only_instance == 0) ?
|
{
|
||||||
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name, "-",
|
if (instance_type & DEFAULT_SINGLE_INSTANCE)
|
||||||
hostname, ".pid", NullS):
|
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name, "-",
|
||||||
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", hostname,
|
hostname, ".pid", NullS);
|
||||||
".pid", NullS);
|
else
|
||||||
|
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", hostname,
|
||||||
|
".pid", NullS);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
(only_instance == 0) ?
|
{
|
||||||
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name,
|
if (instance_type & DEFAULT_SINGLE_INSTANCE)
|
||||||
".pid", NullS):
|
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", instance_name,
|
||||||
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", "mysql",
|
".pid", NullS);
|
||||||
".pid", NullS);
|
else
|
||||||
|
strxnmov(pidfilename, MAX_PATH_LEN - 1, "--pid-file=", "mysql",
|
||||||
|
".pid", NullS);
|
||||||
|
}
|
||||||
|
|
||||||
add_option(pidfilename);
|
add_option(pidfilename);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
don't have to synchronize between threads.
|
don't have to synchronize between threads.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum { USUAL_INSTANCE= 0, DEFAULT_SINGLE_INSTANCE };
|
||||||
|
|
||||||
class Instance_options
|
class Instance_options
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -45,7 +47,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
~Instance_options();
|
~Instance_options();
|
||||||
/* fills in argv */
|
/* fills in argv */
|
||||||
int complete_initialization(const char *default_path, int only_instance);
|
int complete_initialization(const char *default_path, uint instance_type);
|
||||||
|
|
||||||
int add_option(const char* option);
|
int add_option(const char* option);
|
||||||
int init(const char *instance_name_arg);
|
int init(const char *instance_name_arg);
|
||||||
@ -66,7 +68,7 @@ public:
|
|||||||
char **argv;
|
char **argv;
|
||||||
/*
|
/*
|
||||||
Here we cache the version string, obtained from mysqld --version.
|
Here we cache the version string, obtained from mysqld --version.
|
||||||
In the case when mysqld binary is not found we get "unknown" here.
|
In the case when mysqld binary is not found we get NULL here.
|
||||||
*/
|
*/
|
||||||
const char *mysqld_version;
|
const char *mysqld_version;
|
||||||
/* We need the some options, so we store them as a separate pointers */
|
/* We need the some options, so we store them as a separate pointers */
|
||||||
|
@ -163,7 +163,7 @@ void Listener_thread::run()
|
|||||||
unix_socket_address.sun_family= AF_UNIX;
|
unix_socket_address.sun_family= AF_UNIX;
|
||||||
strmake(unix_socket_address.sun_path, options.socket_file_name,
|
strmake(unix_socket_address.sun_path, options.socket_file_name,
|
||||||
sizeof(unix_socket_address.sun_path));
|
sizeof(unix_socket_address.sun_path));
|
||||||
unlink(unix_socket_address.sun_path); // in case we have stale socket file
|
unlink(unix_socket_address.sun_path); /* in case we have stale socket file */
|
||||||
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -76,7 +76,7 @@ static inline void log(FILE *file, const char *format, va_list args)
|
|||||||
if (buff_msg == 0)
|
if (buff_msg == 0)
|
||||||
{
|
{
|
||||||
strmake(buff_stack, "log(): message is too big, my_malloc() failed",
|
strmake(buff_stack, "log(): message is too big, my_malloc() failed",
|
||||||
sizeof(buff_stack));
|
sizeof(buff_stack) - 1);
|
||||||
buff_msg= buff_stack;
|
buff_msg= buff_stack;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
|
|
||||||
#include <my_global.h>
|
#include <my_global.h>
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
#include "parse_output.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <my_sys.h>
|
#include <my_sys.h>
|
||||||
#include <string.h>
|
#include <m_string.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -28,17 +29,17 @@
|
|||||||
SYNOPSYS
|
SYNOPSYS
|
||||||
parse_output_and_get_value()
|
parse_output_and_get_value()
|
||||||
|
|
||||||
command the command to execue with popen.
|
command the command to execue with popen.
|
||||||
word the word to look for (usually an option name)
|
word the word to look for (usually an option name)
|
||||||
result the buffer to store the next word (option value)
|
result the buffer to store the next word (option value)
|
||||||
result_len self-explanatory
|
input_buffer_len self-explanatory
|
||||||
get_all_line flag, which is set if we want to get all the line after
|
flag this equals to GET_LINE if we want to get all the line after
|
||||||
the matched word.
|
the matched word and GET_VALUE otherwise.
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
|
|
||||||
Parse output of the "command". Find the "word" and return the next one
|
Parse output of the "command". Find the "word" and return the next one
|
||||||
if get_all_line is 0. Return the rest of the parsed string otherwise.
|
if flag is GET_VALUE. Return the rest of the parsed string otherwise.
|
||||||
|
|
||||||
RETURN
|
RETURN
|
||||||
0 - ok
|
0 - ok
|
||||||
@ -46,8 +47,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int parse_output_and_get_value(const char *command, const char *word,
|
int parse_output_and_get_value(const char *command, const char *word,
|
||||||
char *result, size_t result_len,
|
char *result, size_t input_buffer_len,
|
||||||
int get_all_line)
|
uint flag)
|
||||||
{
|
{
|
||||||
FILE *output;
|
FILE *output;
|
||||||
uint wordlen;
|
uint wordlen;
|
||||||
@ -68,7 +69,7 @@ int parse_output_and_get_value(const char *command, const char *word,
|
|||||||
|
|
||||||
while (fgets(linebuf, sizeof(linebuf) - 1, output))
|
while (fgets(linebuf, sizeof(linebuf) - 1, output))
|
||||||
{
|
{
|
||||||
uint lineword_len= 0;
|
uint found_word_len= 0;
|
||||||
char *linep= linebuf;
|
char *linep= linebuf;
|
||||||
|
|
||||||
linebuf[sizeof(linebuf) - 1]= '\0'; /* safety */
|
linebuf[sizeof(linebuf) - 1]= '\0'; /* safety */
|
||||||
@ -77,26 +78,24 @@ int parse_output_and_get_value(const char *command, const char *word,
|
|||||||
Get the word, which might contain non-alphanumeric characters. (Usually
|
Get the word, which might contain non-alphanumeric characters. (Usually
|
||||||
these are '/', '-' and '.' in the path expressions and filenames)
|
these are '/', '-' and '.' in the path expressions and filenames)
|
||||||
*/
|
*/
|
||||||
get_word((const char **) &linep, &lineword_len, NONSPACE);
|
get_word((const char **) &linep, &found_word_len, NONSPACE);
|
||||||
if (!strncmp(word, linep, wordlen))
|
if (!strncmp(word, linep, wordlen))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
If we have found the word, return the next one. This is usually
|
If we have found the word, return the next one (this is usually
|
||||||
an option value.
|
an option value) or the whole line (if flag)
|
||||||
*/
|
*/
|
||||||
linep+= lineword_len; /* swallow the previous one */
|
linep+= found_word_len; /* swallow the previous one */
|
||||||
if (!get_all_line)
|
if (flag & GET_VALUE) /* not GET_LINE */
|
||||||
{
|
{
|
||||||
get_word((const char **) &linep, &lineword_len, NONSPACE);
|
get_word((const char **) &linep, &found_word_len, NONSPACE);
|
||||||
if (result_len <= lineword_len)
|
if (input_buffer_len <= found_word_len)
|
||||||
goto err;
|
goto err;
|
||||||
strncpy(result, linep, lineword_len);
|
strmake(result, linep, found_word_len);
|
||||||
result[lineword_len]= '\0';
|
|
||||||
}
|
}
|
||||||
else
|
else /* currently there are only two options */
|
||||||
{
|
{
|
||||||
strncpy(result, linep, result_len);
|
strmake(result, linep, input_buffer_len - 1);
|
||||||
result[result_len]= '\0'; /* safety */
|
|
||||||
}
|
}
|
||||||
goto pclose;
|
goto pclose;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||||
|
|
||||||
|
enum { GET_VALUE= 1, GET_LINE };
|
||||||
|
|
||||||
int parse_output_and_get_value(const char *command, const char *word,
|
int parse_output_and_get_value(const char *command, const char *word,
|
||||||
char *result, size_t result_len,
|
char *result, size_t input_buffer_len,
|
||||||
int get_all_line= 0);
|
uint flag);
|
||||||
|
|
||||||
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
|
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_PARSE_OUTPUT_H */
|
||||||
|
Reference in New Issue
Block a user