summaryrefslogtreecommitdiff
path: root/server-tools
diff options
context:
space:
mode:
Diffstat (limited to 'server-tools')
-rwxr-xr-xserver-tools/CMakeLists.txt18
-rw-r--r--server-tools/Makefile.am1
-rwxr-xr-xserver-tools/instance-manager/CMakeLists.txt17
-rw-r--r--server-tools/instance-manager/Makefile.am3
-rw-r--r--server-tools/instance-manager/instance.cc45
-rw-r--r--server-tools/instance-manager/listener.cc50
-rw-r--r--server-tools/instance-manager/messages.cc6
-rw-r--r--server-tools/instance-manager/portability.h6
8 files changed, 96 insertions, 50 deletions
diff --git a/server-tools/CMakeLists.txt b/server-tools/CMakeLists.txt
new file mode 100755
index 00000000000..1983d459ce2
--- /dev/null
+++ b/server-tools/CMakeLists.txt
@@ -0,0 +1,18 @@
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+
+ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql
+ ${PROJECT_SOURCE_DIR}/extra/yassl/include)
+
+ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc
+ instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc
+ mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc
+ thread_registry.cc user_map.cc imservice.cpp windowsservice.cpp
+ user_management_commands.cc
+ ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c
+ ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c
+ ../../libmysql/errmsg.c)
+
+ADD_DEPENDENCIES(mysqlmanager GenError)
+TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32)
diff --git a/server-tools/Makefile.am b/server-tools/Makefile.am
index ed316b9ac38..573bf07ccff 100644
--- a/server-tools/Makefile.am
+++ b/server-tools/Makefile.am
@@ -1 +1,2 @@
SUBDIRS= instance-manager
+DIST_SUBDIRS= instance-manager
diff --git a/server-tools/instance-manager/CMakeLists.txt b/server-tools/instance-manager/CMakeLists.txt
new file mode 100755
index 00000000000..fafc3df4108
--- /dev/null
+++ b/server-tools/instance-manager/CMakeLists.txt
@@ -0,0 +1,17 @@
+SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+
+ADD_DEFINITIONS(-DMYSQL_SERVER -DMYSQL_INSTANCE_MANAGER)
+INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/sql
+ ${PROJECT_SOURCE_DIR}/extra/yassl/include)
+
+ADD_EXECUTABLE(mysqlmanager buffer.cc command.cc commands.cc guardian.cc instance.cc instance_map.cc
+ instance_options.cc listener.cc log.cc manager.cc messages.cc mysql_connection.cc
+ mysqlmanager.cc options.cc parse.cc parse_output.cc priv.cc protocol.cc
+ thread_registry.cc user_map.cc IMService.cpp WindowsService.cpp
+ ../../sql/net_serv.cc ../../sql-common/pack.c ../../sql/password.c
+ ../../sql/sql_state.c ../../sql-common/client.c ../../libmysql/get_password.c
+ ../../libmysql/errmsg.c)
+
+ADD_DEPENDENCIES(mysqlmanager GenError)
+TARGET_LINK_LIBRARIES(mysqlmanager dbug mysys strings taocrypt vio yassl zlib wsock32)
diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am
index 6b5d80a99af..b1d77506efa 100644
--- a/server-tools/instance-manager/Makefile.am
+++ b/server-tools/instance-manager/Makefile.am
@@ -18,7 +18,8 @@ INCLUDES= @ZLIB_INCLUDES@ -I$(top_srcdir)/include \
@openssl_includes@ -I$(top_builddir)/include
DEFS= -DMYSQL_INSTANCE_MANAGER -DMYSQL_SERVER
-
+EXTRA_DIST = IMService.cpp IMService.h WindowsService.cpp WindowsService.h \
+ CMakeLists.txt
# As all autoconf variables depend from ${prefix} and being resolved only when
# make is run, we can not put these defines to a header file (e.g. to
# default_options.h, generated from default_options.h.in)
diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc
index 5c47dc87734..b792d132da0 100644
--- a/server-tools/instance-manager/instance.cc
+++ b/server-tools/instance-manager/instance.cc
@@ -469,37 +469,38 @@ int Instance::stop()
struct timespec timeout;
uint waitchild= (uint) DEFAULT_SHUTDOWN_DELAY;
- if (options.shutdown_delay_val)
- waitchild= options.shutdown_delay_val;
+ if (is_running())
+ {
+ if (options.shutdown_delay_val)
+ waitchild= options.shutdown_delay_val;
- kill_instance(SIGTERM);
- /* sleep on condition to wait for SIGCHLD */
+ kill_instance(SIGTERM);
+ /* sleep on condition to wait for SIGCHLD */
- timeout.tv_sec= time(NULL) + waitchild;
- timeout.tv_nsec= 0;
- if (pthread_mutex_lock(&LOCK_instance))
- goto err;
+ timeout.tv_sec= time(NULL) + waitchild;
+ timeout.tv_nsec= 0;
+ if (pthread_mutex_lock(&LOCK_instance))
+ return ER_STOP_INSTANCE;
- while (options.get_pid() != 0) /* while server isn't stopped */
- {
- int status;
+ while (options.get_pid() != 0) /* while server isn't stopped */
+ {
+ int status;
- status= pthread_cond_timedwait(&COND_instance_stopped,
- &LOCK_instance,
- &timeout);
- if (status == ETIMEDOUT || status == ETIME)
- break;
- }
+ status= pthread_cond_timedwait(&COND_instance_stopped,
+ &LOCK_instance,
+ &timeout);
+ if (status == ETIMEDOUT || status == ETIME)
+ break;
+ }
- pthread_mutex_unlock(&LOCK_instance);
+ pthread_mutex_unlock(&LOCK_instance);
- kill_instance(SIGKILL);
+ kill_instance(SIGKILL);
- return 0;
+ return 0;
+ }
return ER_INSTANCE_IS_NOT_STARTED;
-err:
- return ER_STOP_INSTANCE;
}
#ifdef __WIN__
diff --git a/server-tools/instance-manager/listener.cc b/server-tools/instance-manager/listener.cc
index 67d798a1700..58a4093dd05 100644
--- a/server-tools/instance-manager/listener.cc
+++ b/server-tools/instance-manager/listener.cc
@@ -36,6 +36,27 @@
#include "portability.h"
+static void set_non_blocking(int socket)
+{
+#ifndef __WIN__
+ int flags= fcntl(socket, F_GETFL, 0);
+ fcntl(socket, F_SETFL, flags | O_NONBLOCK);
+#else
+ u_long arg= 1;
+ ioctlsocket(socket, FIONBIO, &arg);
+#endif
+}
+
+
+static void set_no_inherit(int socket)
+{
+#ifndef __WIN__
+ int flags= fcntl(socket, F_GETFD, 0);
+ fcntl(socket, F_SETFD, flags | FD_CLOEXEC);
+#endif
+}
+
+
/*
Listener_thread - incapsulates listening functionality
*/
@@ -88,7 +109,7 @@ Listener_thread::~Listener_thread()
void Listener_thread::run()
{
- int n= 0;
+ int i, n= 0;
#ifndef __WIN__
/* we use this var to check whether we are running on LinuxThreads */
@@ -117,7 +138,7 @@ void Listener_thread::run()
#endif
/* II. Listen sockets and spawn childs */
- for (int i= 0; i < num_sockets; i++)
+ for (i= 0; i < num_sockets; i++)
n= max(n, sockets[i]);
n++;
@@ -157,6 +178,8 @@ void Listener_thread::run()
/* accept may return -1 (failure or spurious wakeup) */
if (client_fd >= 0) // connection established
{
+ set_no_inherit(client_fd);
+
Vio *vio= vio_new(client_fd, socket_index == 0 ?
VIO_TYPE_SOCKET : VIO_TYPE_TCPIP,
socket_index == 0 ? 1 : 0);
@@ -176,7 +199,7 @@ void Listener_thread::run()
log_info("Listener_thread::run(): shutdown requested, exiting...");
- for (int i= 0; i < num_sockets; i++)
+ for (i= 0; i < num_sockets; i++)
close(sockets[i]);
#ifndef __WIN__
@@ -189,7 +212,7 @@ void Listener_thread::run()
err:
// we have to close the ip sockets in case of error
- for (int i= 0; i < num_sockets; i++)
+ for (i= 0; i < num_sockets; i++)
close(sockets[i]);
thread_registry.unregister_thread(&thread_info);
@@ -198,25 +221,6 @@ err:
return;
}
-void set_non_blocking(int socket)
-{
-#ifndef __WIN__
- int flags= fcntl(socket, F_GETFL, 0);
- fcntl(socket, F_SETFL, flags | O_NONBLOCK);
-#else
- u_long arg= 1;
- ioctlsocket(socket, FIONBIO, &arg);
-#endif
-}
-
-void set_no_inherit(int socket)
-{
-#ifndef __WIN__
- int flags= fcntl(socket, F_GETFD, 0);
- fcntl(socket, F_SETFD, flags | FD_CLOEXEC);
-#endif
-}
-
int Listener_thread::create_tcp_socket()
{
/* value to be set by setsockopt */
diff --git a/server-tools/instance-manager/messages.cc b/server-tools/instance-manager/messages.cc
index a9b00b9e01f..d2595638de0 100644
--- a/server-tools/instance-manager/messages.cc
+++ b/server-tools/instance-manager/messages.cc
@@ -48,8 +48,8 @@ static const char *mysqld_error_message(unsigned sql_errno)
case ER_BAD_INSTANCE_NAME:
return "Bad instance name. Check that the instance with such a name exists";
case ER_INSTANCE_IS_NOT_STARTED:
- return "Cannot stop instance. Perhaps the instance is not started, or was started"
- "manually, so IM cannot find the pidfile.";
+ return "Cannot stop instance. Perhaps the instance is not started, or was"
+ " started manually, so IM cannot find the pidfile.";
case ER_INSTANCE_ALREADY_STARTED:
return "The instance is already started";
case ER_CANNOT_START_INSTANCE:
@@ -67,7 +67,7 @@ static const char *mysqld_error_message(unsigned sql_errno)
return "Cannot open log file";
case ER_GUESS_LOGFILE:
return "Cannot guess the log filename. Try specifying full log name"
- "in the instance options";
+ " in the instance options";
case ER_ACCESS_OPTION_FILE:
return "Cannot open the option file to edit. Check permissions";
default:
diff --git a/server-tools/instance-manager/portability.h b/server-tools/instance-manager/portability.h
index 1a3be5705e3..23a5a5bd14c 100644
--- a/server-tools/instance-manager/portability.h
+++ b/server-tools/instance-manager/portability.h
@@ -1,7 +1,11 @@
#ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_PORTABILITY_H
#define INCLUDES_MYSQL_INSTANCE_MANAGER_PORTABILITY_H
-#if defined(_SCO_DS) && !defined(SHUT_RDWR)
+#if (defined(_SCO_DS) || defined(UNIXWARE_7)) && !defined(SHUT_RDWR)
+/*
+ SHUT_* functions are defined only if
+ "(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 >= 1)"
+*/
#define SHUT_RDWR 2
#endif