summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager/instance_options.cc
diff options
context:
space:
mode:
authorunknown <kostja@bodhi.local>2006-11-18 01:34:44 +0300
committerunknown <kostja@bodhi.local>2006-11-18 01:34:44 +0300
commitc95482d4539adc271ac41fa75b70d5d6b696634f (patch)
tree8edacec17e19484691a25cc8da80c303515238f9 /server-tools/instance-manager/instance_options.cc
parent08df05560edb4beeccdf605f43008750731f6e18 (diff)
downloadmariadb-git-c95482d4539adc271ac41fa75b70d5d6b696634f.tar.gz
Port cleanups, trivial refactoring and code rearrangements from
Alik's patch for BUG#22306: STOP INSTANCE can not be applied for instances in Crashed, Failed and Abandoned" to ease review process. Evaluate global variable linuxthreads before starting threads to avoid a race. server-tools/instance-manager/buffer.cc: Fix spelling. server-tools/instance-manager/command.h: Fix spelling. server-tools/instance-manager/commands.cc: Fix spelling. server-tools/instance-manager/commands.h: Fix spelling, tidy up. server-tools/instance-manager/guardian.cc: Cleanup logging, options.get_shutdown_delay() is a method, tidy up. server-tools/instance-manager/instance.cc: Rearrange methods to be the same as in Alik's patch, fix spelling errors, clean up logging texts, port comments from Alik's patch, implement some basic renames from his patch. No real changes. server-tools/instance-manager/instance.h: Tidy up, renames. server-tools/instance-manager/instance_map.cc: Fix spellings, port some refactoring from Alik's patch. server-tools/instance-manager/instance_map.h: Cleanup. server-tools/instance-manager/instance_options.cc: Cleanup. Implement Instance_options::get_shutdown_delay() and Instance_options::get_mysqld_port(). server-tools/instance-manager/instance_options.h: Cleanup. server-tools/instance-manager/listener.cc: Cleanup. server-tools/instance-manager/log.cc: Fix spelling. server-tools/instance-manager/manager.cc: Cleanup. server-tools/instance-manager/manager.h: Add getters for Manager members. server-tools/instance-manager/mysqlmanager.cc: Evaluate linuxthreads before starting threads to avoid a race. server-tools/instance-manager/parse_output.cc: Fix spelling. server-tools/instance-manager/priv.cc: Cleanup. server-tools/instance-manager/priv.h: Cleanup. server-tools/instance-manager/user_management_commands.cc: Fix spelling. server-tools/instance-manager/user_management_commands.h: Fix spelling. server-tools/instance-manager/user_map.cc: Fix spelling.
Diffstat (limited to 'server-tools/instance-manager/instance_options.cc')
-rw-r--r--server-tools/instance-manager/instance_options.cc96
1 files changed, 64 insertions, 32 deletions
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index 00da6660703..cbdf0a61258 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -29,6 +29,7 @@
#include "buffer.h"
#include "instance.h"
#include "log.h"
+#include "options.h"
#include "parse_output.h"
#include "priv.h"
@@ -82,8 +83,12 @@ bool Instance_options::is_option_im_specific(const char *option_name)
Instance_options::Instance_options()
:mysqld_version(NULL), mysqld_socket(NULL), mysqld_datadir(NULL),
- mysqld_pid_file(NULL), mysqld_port(NULL), mysqld_port_val(0),
- nonguarded(NULL), shutdown_delay(NULL), shutdown_delay_val(0),
+ mysqld_pid_file(NULL),
+ nonguarded(NULL),
+ mysqld_port(NULL),
+ mysqld_port_val(0),
+ shutdown_delay(NULL),
+ shutdown_delay_val(0),
filled_default_options(0)
{
mysqld_path.str= NULL;
@@ -99,7 +104,7 @@ Instance_options::Instance_options()
/*
Get compiled-in value of default_option
- SYNOPSYS
+ SYNOPSIS
get_default_option()
result buffer to put found value
result_len buffer size
@@ -139,7 +144,7 @@ err:
/*
Fill mysqld_version option (used at initialization stage)
- SYNOPSYS
+ SYNOPSIS
fill_instance_version()
DESCRIPTION
@@ -182,7 +187,7 @@ int Instance_options::fill_instance_version()
err:
if (rc)
log_error("fill_instance_version: Failed to get version of '%s'",
- mysqld_path.str);
+ (const char *) mysqld_path.str);
return rc;
}
@@ -190,7 +195,7 @@ err:
/*
Fill mysqld_real_path
- SYNOPSYS
+ SYNOPSIS
fill_mysqld_real_path()
DESCRIPTION
@@ -242,7 +247,7 @@ err:
/*
Fill various log options
- SYNOPSYS
+ SYNOPSIS
fill_log_options()
DESCRIPTION
@@ -355,7 +360,7 @@ err:
/*
Get the full pid file name with path
- SYNOPSYS
+ SYNOPSIS
get_pid_filaname()
result buffer to sotre the pidfile value
@@ -396,7 +401,7 @@ int Instance_options::unlink_pidfile()
}
-pid_t Instance_options::get_pid()
+pid_t Instance_options::load_pid()
{
FILE *pid_file_stream;
@@ -415,7 +420,7 @@ pid_t Instance_options::get_pid()
}
-int Instance_options::complete_initialization(const char *default_path)
+bool Instance_options::complete_initialization()
{
int arg_idx;
const char *tmp;
@@ -423,10 +428,14 @@ int Instance_options::complete_initialization(const char *default_path)
if (!mysqld_path.str)
{
- // Need one extra byte, as convert_dirname() adds a slash at the end.
- if (!(mysqld_path.str= alloc_root(&alloc, strlen(default_path) + 2)))
- goto err;
- strcpy(mysqld_path.str, default_path);
+ /* Need one extra byte, as convert_dirname() adds a slash at the end. */
+ mysqld_path.str= alloc_root(&alloc,
+ strlen(Options::Main::default_mysqld_path) + 2);
+
+ if (! mysqld_path.str)
+ return TRUE;
+
+ strcpy(mysqld_path.str, Options::Main::default_mysqld_path);
}
// it's safe to cast this to char* since this is a buffer we are allocating
@@ -442,7 +451,7 @@ int Instance_options::complete_initialization(const char *default_path)
shutdown_delay_val= atoi(shutdown_delay);
if (!(tmp= strdup_root(&alloc, "--no-defaults")))
- goto err;
+ return TRUE;
if (!mysqld_pid_file)
{
@@ -477,21 +486,21 @@ int Instance_options::complete_initialization(const char *default_path)
}
if (get_pid_filename(pid_file_with_path))
- goto err;
+ return TRUE;
/* we need to reserve space for the final zero + possible default options */
if (!(argv= (char**)
alloc_root(&alloc, (get_num_options() + 1
+ MAX_NUMBER_OF_DEFAULT_OPTIONS) * sizeof(char*))))
- goto err;
+ return TRUE;
filled_default_options= 0;
/* the path must be first in the argv */
if (add_to_argv(mysqld_path.str))
- goto err;
+ return TRUE;
if (add_to_argv(tmp))
- goto err;
+ return TRUE;
arg_idx= filled_default_options;
for (int opt_idx= 0; opt_idx < get_num_options(); ++opt_idx)
@@ -514,12 +523,9 @@ int Instance_options::complete_initialization(const char *default_path)
argv[arg_idx]= 0;
if (fill_log_options() || fill_mysqld_real_path() || fill_instance_version())
- goto err;
-
- return 0;
+ return TRUE;
-err:
- return 1;
+ return FALSE;
}
@@ -636,26 +642,26 @@ void Instance_options::print_argv()
/*
We execute this function to initialize some options.
- Return value: 0 - ok. 1 - unable to allocate memory.
+
+ RETURN
+ FALSE - ok
+ TRUE - memory allocation error
*/
-int Instance_options::init(const LEX_STRING *instance_name_arg)
+bool Instance_options::init(const LEX_STRING *instance_name_arg)
{
instance_name.length= instance_name_arg->length;
init_alloc_root(&alloc, MEM_ROOT_BLOCK_SIZE, 0);
if (options.init())
- goto err;
+ return TRUE;
if (!(instance_name.str= strmake_root(&alloc, instance_name_arg->str,
instance_name_arg->length)))
- goto err;
-
- return 0;
+ return TRUE;
-err:
- return 1;
+ return FALSE;
}
@@ -663,3 +669,29 @@ Instance_options::~Instance_options()
{
free_root(&alloc, MYF(0));
}
+
+
+uint Instance_options::get_shutdown_delay() const
+{
+ static const uint DEFAULT_SHUTDOWN_DELAY= 35;
+
+ /*
+ NOTE: it is important to check shutdown_delay here, but use
+ shutdown_delay_val. The idea is that if the option is unset,
+ shutdown_delay will be NULL, but shutdown_delay_val will not be reset.
+ */
+
+ return shutdown_delay ? shutdown_delay_val : DEFAULT_SHUTDOWN_DELAY;
+}
+
+int Instance_options::get_mysqld_port() const
+{
+ /*
+ NOTE: it is important to check mysqld_port here, but use mysqld_port_val.
+ The idea is that if the option is unset, mysqld_port will be NULL, but
+ mysqld_port_val will not be reset.
+ */
+
+ return mysqld_port ? mysqld_port_val : 0;
+}
+