mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
post-review fixes
server-tools/instance-manager/Makefile.am: Removed entry for deleted file server-tools/instance-manager/buffer.cc: cleanup server-tools/instance-manager/commands.cc: cleanup, added missing error handling server-tools/instance-manager/instance.cc: added waitpid in instance_start, added few checks server-tools/instance-manager/instance_map.cc: error handling for hash_init added server-tools/instance-manager/instance_map.h: Extended constructor server-tools/instance-manager/instance_options.cc: made add_option less bulky server-tools/instance-manager/instance_options.h: - server-tools/instance-manager/listener.cc: added missing close, fixed typo server-tools/instance-manager/manager.cc: moved some Instance_map initialization to costructor server-tools/instance-manager/protocol.cc: error handling added server-tools/instance-manager/protocol.h: store_to_string fixed to return a value server-tools/instance-manager/user_map.cc: error handling for hash_init added server-tools/instance-manager/user_map.h: added init() for User map (becouse of the hash_init check)
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
#include <my_sys.h>
|
||||
#include <signal.h>
|
||||
#include <m_string.h>
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
/*
|
||||
The method starts an instance.
|
||||
@ -41,11 +41,12 @@
|
||||
|
||||
int Instance::start()
|
||||
{
|
||||
pid_t pid;
|
||||
|
||||
if (!is_running())
|
||||
{
|
||||
log_info("trying to start instance %s", options.instance_name);
|
||||
switch (fork()) {
|
||||
switch (pid= fork()) {
|
||||
case 0:
|
||||
if (fork()) /* zombie protection */
|
||||
exit(0); /* parent goes bye-bye */
|
||||
@ -57,6 +58,7 @@ int Instance::start()
|
||||
case -1:
|
||||
return ER_CANNOT_START_INSTANCE;
|
||||
default:
|
||||
waitpid(pid, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -77,21 +79,32 @@ int Instance::cleanup()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Instance::~Instance()
|
||||
{
|
||||
pthread_mutex_destroy(&LOCK_instance);
|
||||
}
|
||||
|
||||
|
||||
bool Instance::is_running()
|
||||
{
|
||||
uint port;
|
||||
const char *socket;
|
||||
|
||||
if (options.mysqld_port)
|
||||
port= atoi(strchr(options.mysqld_port, '=') + 1);
|
||||
|
||||
if (options.mysqld_socket)
|
||||
socket= strchr(options.mysqld_socket, '=') + 1;
|
||||
|
||||
pthread_mutex_lock(&LOCK_instance);
|
||||
if (!is_connected)
|
||||
{
|
||||
mysql_init(&mysql);
|
||||
if (mysql_real_connect(&mysql, LOCAL_HOST, options.mysqld_user,
|
||||
options.mysqld_password,
|
||||
NullS, atoi(strchr(options.mysqld_port, '=') + 1),
|
||||
strchr(options.mysqld_socket, '=') + 1, 0))
|
||||
NullS, port,
|
||||
socket, 0))
|
||||
{
|
||||
is_connected= TRUE;
|
||||
pthread_mutex_unlock(&LOCK_instance);
|
||||
|
Reference in New Issue
Block a user