summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/instance_options.cc
diff options
context:
space:
mode:
authorunknown <anozdrin/alik@booka.>2006-11-21 17:47:14 +0300
committerunknown <anozdrin/alik@booka.>2006-11-21 17:47:14 +0300
commit7c35c3d5e66b350b59fb0aaef4d1cc97f332bea7 (patch)
tree013e928c88c019dc5bfaa9bd7713f68f41037ac5 /server-tools/instance-manager/instance_options.cc
parentcbfff7304d60f56853bb1312dbe6fe42ebbeffee (diff)
downloadmariadb-git-7c35c3d5e66b350b59fb0aaef4d1cc97f332bea7.tar.gz
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: Log polishing. server-tools/instance-manager/commands.cc: Log polishing. server-tools/instance-manager/commands.h: Eliminate warnings. server-tools/instance-manager/instance.cc: Log polishing. server-tools/instance-manager/instance_map.cc: Log polishing. server-tools/instance-manager/instance_options.cc: 1) Log polishing. 2) Change int-return type to bool. server-tools/instance-manager/instance_options.h: Change int-return type to bool. server-tools/instance-manager/listener.cc: Log polishing. server-tools/instance-manager/log.cc: Log polishing. server-tools/instance-manager/log.h: Log polishing. server-tools/instance-manager/manager.cc: Log polishing. server-tools/instance-manager/mysql_connection.cc: Log polishing. server-tools/instance-manager/mysql_connection.h: Change int-return type to bool. server-tools/instance-manager/mysqlmanager.cc: Log polishing. server-tools/instance-manager/priv.cc: Log polishing. server-tools/instance-manager/thread_registry.cc: 1. Print pthread_t as (unsigned long), not as (signed long) to avoid negative identifiers in output. 2. Print thread id after it will be initialized, not before. server-tools/instance-manager/user_map.cc: Log polishing.
Diffstat (limited to 'server-tools/instance-manager/instance_options.cc')
-rw-r--r--server-tools/instance-manager/instance_options.cc85
1 files changed, 48 insertions, 37 deletions
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index cbdf0a61258..3400e1e10f5 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -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(Buffer *buf,
/* 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_version()
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_path()
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;
}