1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

IM port cleanup

server-tools/instance-manager/IMService.cpp:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.cpp:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/WindowsService.h:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/instance.cc:
  cleanup & coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/listener.cc:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/manager.cc:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/options.cc:
  coding style fixes: tabs, trailing spaces, offset e.t.c
server-tools/instance-manager/user_map.cc:
  simplify password file processing
This commit is contained in:
unknown
2005-08-05 17:02:06 +04:00
parent d976f87fb4
commit cd3fa684ce
8 changed files with 205 additions and 219 deletions

View File

@ -69,4 +69,3 @@ int HandleServiceOptions(Options options)
return (int)winService.Init(); return (int)winService.Init();
return ret_val; return ret_val;
} }

View File

@ -155,8 +155,7 @@ void WindowsService::RegisterAndRun(DWORD argc, LPTSTR *argv)
void WindowsService::HandleControlCode(DWORD opcode) void WindowsService::HandleControlCode(DWORD opcode)
{ {
// Handle the requested control code. // Handle the requested control code.
switch(opcode) switch(opcode) {
{
case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_STOP:
// Stop the service. // Stop the service.
status.dwCurrentState= SERVICE_STOP_PENDING; status.dwCurrentState= SERVICE_STOP_PENDING;
@ -201,5 +200,3 @@ void WINAPI WindowsService::ControlHandler(DWORD opcode)
return gService->HandleControlCode(opcode); return gService->HandleControlCode(opcode);
} }

View File

@ -41,4 +41,3 @@ protected:
void HandleControlCode(DWORD opcode); void HandleControlCode(DWORD opcode);
void RegisterAndRun(DWORD argc, LPTSTR *argv); void RegisterAndRun(DWORD argc, LPTSTR *argv);
}; };

View File

@ -121,8 +121,7 @@ int Instance::launch_and_wait()
{ {
pid_t pid= fork(); pid_t pid= fork();
switch (pid) switch (pid) {
{
case 0: case 0:
execv(options.mysqld_path, options.argv); execv(options.mysqld_path, options.argv);
/* exec never returns */ /* exec never returns */
@ -215,8 +214,8 @@ void Instance::fork_and_monitor()
{ {
log_info("starting instance %s", options.instance_name); log_info("starting instance %s", options.instance_name);
int result= launch_and_wait(); if (launch_and_wait())
if (result == -1) return; return; /* error is logged */
/* set instance state to crashed */ /* set instance state to crashed */
pthread_mutex_lock(&LOCK_instance); pthread_mutex_lock(&LOCK_instance);
@ -233,9 +232,6 @@ void Instance::fork_and_monitor()
pthread_cond_signal(&instance_map->guardian->COND_guardian); pthread_cond_signal(&instance_map->guardian->COND_guardian);
/* thread exits */ /* thread exits */
return; return;
/* we should never end up here */
DBUG_ASSERT(0);
} }
@ -268,9 +264,9 @@ bool Instance::is_running()
MYSQL mysql; MYSQL mysql;
uint port= 0; uint port= 0;
const char *socket= NULL; const char *socket= NULL;
const char *password= "check_connection"; static const char *password= "check_connection";
const char *username= "MySQL_Instance_Manager"; static const char *username= "MySQL_Instance_Manager";
const char *access_denied_message= "Access denied for user"; static const char *access_denied_message= "Access denied for user";
bool return_val; bool return_val;
if (options.mysqld_port) if (options.mysqld_port)
@ -299,15 +295,8 @@ bool Instance::is_running()
return_val= TRUE; /* server is alive */ return_val= TRUE; /* server is alive */
} }
else else
{ return_val= test(!strncmp(access_denied_message, mysql_error(&mysql),
if (!strncmp(access_denied_message, mysql_error(&mysql), sizeof(access_denied_message) - 1));
sizeof(access_denied_message)-1))
{
return_val= TRUE;
}
else
return_val= FALSE;
}
mysql_close(&mysql); mysql_close(&mysql);
pthread_mutex_unlock(&LOCK_instance); pthread_mutex_unlock(&LOCK_instance);

View File

@ -273,8 +273,8 @@ int Listener_thread::create_tcp_socket()
} }
#ifndef __WIN__ #ifndef __WIN__
int Listener_thread::create_unix_socket( int Listener_thread::create_unix_socket(struct sockaddr_un
struct sockaddr_un &unix_socket_address) &unix_socket_address)
{ {
int unix_socket= socket(AF_UNIX, SOCK_STREAM, 0); int unix_socket= socket(AF_UNIX, SOCK_STREAM, 0);
if (unix_socket == INVALID_SOCKET) if (unix_socket == INVALID_SOCKET)
@ -322,7 +322,8 @@ int Listener_thread::create_unix_socket(
/* make sure that instances won't be listening our sockets */ /* make sure that instances won't be listening our sockets */
set_no_inherit(unix_socket); set_no_inherit(unix_socket);
log_info("accepting connections on unix socket %s", unix_socket_address.sun_path); log_info("accepting connections on unix socket %s",
unix_socket_address.sun_path);
sockets[num_sockets++]= unix_socket; sockets[num_sockets++]= unix_socket;
FD_SET(unix_socket, &read_fds); FD_SET(unix_socket, &read_fds);
return 0; return 0;

View File

@ -112,11 +112,12 @@ static struct my_option my_long_options[] =
{ "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL" { "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL"
" Server binary.", " Server binary.",
(gptr *) &Options::default_mysqld_path, (gptr *) &Options::default_mysqld_path, (gptr *) &Options::default_mysqld_path,
(gptr *) &Options::default_mysqld_path,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor instances" { "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor"
" in seconds.", " instances in seconds.",
(gptr *) &Options::monitoring_interval, (gptr *) &Options::monitoring_interval,
(gptr *) &Options::monitoring_interval, (gptr *) &Options::monitoring_interval,
0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL, 0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,

View File

@ -25,6 +25,12 @@
#include "log.h" #include "log.h"
#ifdef __WIN__
#define NEWLINE_LEN 2
#else
#define NEWLINE_LEN 1
#endif
struct User struct User
{ {
char user[USERNAME_LENGTH + 1]; char user[USERNAME_LENGTH + 1];
@ -36,8 +42,7 @@ struct User
int User::init(const char *line) int User::init(const char *line)
{ {
const char *name_begin, *name_end; const char *name_begin, *name_end, *password;
char *password;
if (line[0] == '\'' || line[0] == '"') if (line[0] == '\'' || line[0] == '"')
{ {
@ -45,7 +50,7 @@ int User::init(const char *line)
name_end= strchr(name_begin, line[0]); name_end= strchr(name_begin, line[0]);
if (name_end == 0 || name_end[1] != ':') if (name_end == 0 || name_end[1] != ':')
goto err; goto err;
password= (char*)(name_end + 2); password= name_end + 2;
} }
else else
{ {
@ -53,19 +58,14 @@ int User::init(const char *line)
name_end= strchr(name_begin, ':'); name_end= strchr(name_begin, ':');
if (name_end == 0) if (name_end == 0)
goto err; goto err;
password= (char*)(name_end + 1); password= name_end + 1;
} }
user_length= name_end - name_begin; user_length= name_end - name_begin;
if (user_length > USERNAME_LENGTH) if (user_length > USERNAME_LENGTH)
goto err; goto err;
/* assume that newline characater is present */ /* assume that newline characater is present */
if (password[strlen(password)-2] == '\r') if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + NEWLINE_LEN)
{
password[strlen(password)-2]= '\n';
password[strlen(password)-1]= 0;
}
if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + 1)
goto err; goto err;
memcpy(user, name_begin, user_length); memcpy(user, name_begin, user_length);