summaryrefslogtreecommitdiff
path: root/server-tools/instance-manager
diff options
context:
space:
mode:
Diffstat (limited to 'server-tools/instance-manager')
-rw-r--r--server-tools/instance-manager/commands.cc6
-rw-r--r--server-tools/instance-manager/instance.cc2
-rw-r--r--server-tools/instance-manager/instance_map.cc2
-rw-r--r--server-tools/instance-manager/instance_options.cc15
-rw-r--r--server-tools/instance-manager/manager.cc43
-rw-r--r--server-tools/instance-manager/options.cc12
-rw-r--r--server-tools/instance-manager/priv.cc2
-rw-r--r--server-tools/instance-manager/user_management_commands.cc4
-rw-r--r--server-tools/instance-manager/user_management_commands.h7
9 files changed, 59 insertions, 34 deletions
diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc
index 07e1e9a18f3..f45b230171e 100644
--- a/server-tools/instance-manager/commands.cc
+++ b/server-tools/instance-manager/commands.cc
@@ -695,7 +695,7 @@ bool Create_instance::parse_args(const char **text)
if (!option_value_str)
{
- LEX_STRING empty_str= { C_STRING_WITH_SIZE("") };
+ LEX_STRING empty_str= { C_STRING_WITH_LEN("") };
if (!(option_value_str= Named_value::alloc_str(&empty_str)))
return TRUE; /* out of memory during parsing. */
@@ -1511,7 +1511,7 @@ bool Set_option::parse_args(const char **text)
if (!option_value_str)
{
- LEX_STRING empty_str= { C_STRING_WITH_SIZE("") };
+ LEX_STRING empty_str= { C_STRING_WITH_LEN("") };
if (!(option_value_str= Named_value::alloc_str(&empty_str)))
return TRUE; /* out of memory during parsing. */
@@ -1650,7 +1650,7 @@ bool Unset_option::parse_args(const char **text)
return TRUE; /* out of memory during parsing. */
{
- LEX_STRING empty_str= { C_STRING_WITH_SIZE("") };
+ LEX_STRING empty_str= { C_STRING_WITH_LEN("") };
if (!(option_value_str= Named_value::alloc_str(&empty_str)))
{
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 456052bf7e5..340a2d67353 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -37,7 +37,7 @@
const LEX_STRING
-Instance::DFLT_INSTANCE_NAME= { C_STRING_WITH_SIZE("mysqld") };
+Instance::DFLT_INSTANCE_NAME= { C_STRING_WITH_LEN("mysqld") };
static const char * const INSTANCE_NAME_PREFIX= Instance::DFLT_INSTANCE_NAME.str;
static const int INSTANCE_NAME_PREFIX_LEN= Instance::DFLT_INSTANCE_NAME.length;
diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc
index c9608fa7c14..ec73fb7d73a 100644
--- a/server-tools/instance-manager/instance_map.cc
+++ b/server-tools/instance-manager/instance_map.cc
@@ -293,7 +293,7 @@ int Instance_map::flush_instances()
get_instance_key, delete_instance, 0);
rc= load();
- guardian->init();
+ guardian->init(); // TODO: check error status.
return rc;
}
diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc
index b05e40734b7..576096adfd2 100644
--- a/server-tools/instance-manager/instance_options.cc
+++ b/server-tools/instance-manager/instance_options.cc
@@ -120,7 +120,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,
{
int rc= 1;
LEX_STRING verbose_option=
- { C_STRING_WITH_SIZE(" --no-defaults --verbose --help") };
+ { C_STRING_WITH_LEN(" --no-defaults --verbose --help") };
/* reserve space for the path + option + final '\0' */
Buffer cmd(mysqld_path.length + verbose_option.length + 1);
@@ -155,7 +155,7 @@ int Instance_options::fill_instance_version()
{
char result[MAX_VERSION_LENGTH];
LEX_STRING version_option=
- { C_STRING_WITH_SIZE(" --no-defaults --version") };
+ { C_STRING_WITH_LEN(" --no-defaults --version") };
int rc= 1;
Buffer cmd(mysqld_path.length + version_option.length + 1);
@@ -210,7 +210,7 @@ int Instance_options::fill_mysqld_real_path()
{
char result[FN_REFLEN];
LEX_STRING help_option=
- { C_STRING_WITH_SIZE(" --no-defaults --help") };
+ { C_STRING_WITH_LEN(" --no-defaults --help") };
int rc= 1;
Buffer cmd(mysqld_path.length + help_option.length);
@@ -420,8 +420,13 @@ int Instance_options::complete_initialization(const char *default_path)
const char *tmp;
char *end;
- if (!mysqld_path.str && !(mysqld_path.str= strdup_root(&alloc, default_path)))
- goto err;
+ 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);
+ }
// it's safe to cast this to char* since this is a buffer we are allocating
end= convert_dirname((char*)mysqld_path.str, mysqld_path.str, NullS);
diff --git a/server-tools/instance-manager/manager.cc b/server-tools/instance-manager/manager.cc
index 599131089ed..d2d498eebf1 100644
--- a/server-tools/instance-manager/manager.cc
+++ b/server-tools/instance-manager/manager.cc
@@ -198,6 +198,25 @@ void manager()
if (create_pid_file(Options::Main::pid_file_name, manager_pid))
return; /* necessary logging has been already done. */
+ /*
+ Initialize signals and alarm-infrastructure.
+
+ NOTE: To work nicely with LinuxThreads, the signal thread is the first
+ thread in the process.
+
+ NOTE:
+ After init_thr_alarm() call it's possible to call thr_alarm() (from
+ different threads), that results in sending ALARM signal to the alarm
+ thread (which can be the main thread). That signal can interrupt
+ blocking calls.
+
+ In other words, a blocking call can be interrupted in the main thread
+ after init_thr_alarm().
+ */
+
+ sigset_t mask;
+ set_signals(&mask);
+
/* create guardian thread */
{
pthread_t guardian_thd_id;
@@ -205,9 +224,16 @@ void manager()
int rc;
/*
- NOTE: Guardian should be shutdown first. Only then all other threads
- need to be stopped. This should be done, as guardian is responsible for
- shutting down the instances, and this is a long operation.
+ NOTE: Guardian should be shutdown first. Only then all other threads
+ need to be stopped. This should be done, as guardian is responsible
+ for shutting down the instances, and this is a long operation.
+
+ NOTE: Guardian uses thr_alarm() when detects current state of
+ instances (is_running()), but it is not interfere with
+ flush_instances() later in the code, because until flush_instances()
+ complete in the main thread, Guardian thread is not permitted to
+ process instances. And before flush_instances() there is no instances
+ to proceed.
*/
pthread_attr_init(&guardian_thd_attr);
@@ -223,10 +249,8 @@ void manager()
}
- /*
- To work nicely with LinuxThreads, the signal thread is the first thread
- in the process.
- */
+ /* Load instances. */
+
{
instance_map.guardian->lock();
@@ -246,11 +270,6 @@ void manager()
}
}
- /* Initialize signals and alarm-infrastructure. */
-
- sigset_t mask;
- set_signals(&mask);
-
/* create the listener */
{
pthread_t listener_thd_id;
diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc
index 31ce5b00190..07a1fd3e932 100644
--- a/server-tools/instance-manager/options.cc
+++ b/server-tools/instance-manager/options.cc
@@ -114,7 +114,6 @@ static const int ANGEL_PID_FILE_SUFFIX_LEN= strlen(ANGEL_PID_FILE_SUFFIX);
*/
enum options {
- OPT_PASSWD= 'P',
OPT_USERNAME= 'u',
OPT_PASSWORD= 'p',
OPT_LOG= 256,
@@ -135,6 +134,7 @@ enum options {
OPT_PORT,
OPT_WAIT_TIMEOUT,
OPT_BIND_ADDRESS,
+ OPT_PRINT_PASSWORD_LINE,
OPT_ADD_USER,
OPT_DROP_USER,
OPT_EDIT_USER,
@@ -225,8 +225,8 @@ static struct my_option my_long_options[] =
(gptr *) &Options::Main::mysqld_safe_compatible,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
- { "passwd", OPT_PASSWD,
- "Prepare an entry for the password file and exit.",
+ { "print-password-line", OPT_PRINT_PASSWORD_LINE,
+ "Print out a user entry as a line for the password file and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "password", OPT_PASSWORD, "Password to update the password file",
@@ -339,7 +339,7 @@ get_one_option(int optid,
case 'V':
version();
exit(0);
- case OPT_PASSWD:
+ case OPT_PRINT_PASSWORD_LINE:
case OPT_ADD_USER:
case OPT_DROP_USER:
case OPT_EDIT_USER:
@@ -354,8 +354,8 @@ get_one_option(int optid,
}
switch (optid) {
- case OPT_PASSWD:
- Options::User_management::cmd= new Passwd_cmd();
+ case OPT_PRINT_PASSWORD_LINE:
+ Options::User_management::cmd= new Print_password_line_cmd();
break;
case OPT_ADD_USER:
Options::User_management::cmd= new Add_user_cmd();
diff --git a/server-tools/instance-manager/priv.cc b/server-tools/instance-manager/priv.cc
index d3cc52ec638..3dae900d84b 100644
--- a/server-tools/instance-manager/priv.cc
+++ b/server-tools/instance-manager/priv.cc
@@ -43,7 +43,7 @@ bool linuxthreads;
The following string must be less then 80 characters, as
mysql_connection.cc relies on it
*/
-const LEX_STRING mysqlmanager_version= { C_STRING_WITH_SIZE("1.0-beta") };
+const LEX_STRING mysqlmanager_version= { C_STRING_WITH_LEN("1.0-beta") };
const unsigned char protocol_version= PROTOCOL_VERSION;
diff --git a/server-tools/instance-manager/user_management_commands.cc b/server-tools/instance-manager/user_management_commands.cc
index 03a3f9814e3..20ebeb0d6bf 100644
--- a/server-tools/instance-manager/user_management_commands.cc
+++ b/server-tools/instance-manager/user_management_commands.cc
@@ -180,10 +180,10 @@ static int save_password_file(User_map *user_map)
}
/*************************************************************************
- Passwd_cmd
+ Print_password_line_cmd
*************************************************************************/
-int Passwd_cmd::execute()
+int Print_password_line_cmd::execute()
{
LEX_STRING user_name;
const char *password;
diff --git a/server-tools/instance-manager/user_management_commands.h b/server-tools/instance-manager/user_management_commands.h
index 4bf3546f0a6..8d820be5ec7 100644
--- a/server-tools/instance-manager/user_management_commands.h
+++ b/server-tools/instance-manager/user_management_commands.h
@@ -61,13 +61,14 @@ public:
/*************************************************************************
- Passwd_cmd: support for --passwd command-line option.
+ Print_password_line_cmd: support for --print-password-line command-line
+ option.
*************************************************************************/
-class Passwd_cmd : public User_management_cmd
+class Print_password_line_cmd : public User_management_cmd
{
public:
- Passwd_cmd()
+ Print_password_line_cmd()
{ }
public: