mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
IM port cleanup
This commit is contained in:
@ -69,4 +69,3 @@ int HandleServiceOptions(Options options)
|
||||
return (int)winService.Init();
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
|
@ -155,8 +155,7 @@ void WindowsService::RegisterAndRun(DWORD argc, LPTSTR *argv)
|
||||
void WindowsService::HandleControlCode(DWORD opcode)
|
||||
{
|
||||
// Handle the requested control code.
|
||||
switch(opcode)
|
||||
{
|
||||
switch(opcode) {
|
||||
case SERVICE_CONTROL_STOP:
|
||||
// Stop the service.
|
||||
status.dwCurrentState= SERVICE_STOP_PENDING;
|
||||
@ -201,5 +200,3 @@ void WINAPI WindowsService::ControlHandler(DWORD opcode)
|
||||
|
||||
return gService->HandleControlCode(opcode);
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,4 +41,3 @@ protected:
|
||||
void HandleControlCode(DWORD opcode);
|
||||
void RegisterAndRun(DWORD argc, LPTSTR *argv);
|
||||
};
|
||||
|
||||
|
@ -121,8 +121,7 @@ int Instance::launch_and_wait()
|
||||
{
|
||||
pid_t pid= fork();
|
||||
|
||||
switch (pid)
|
||||
{
|
||||
switch (pid) {
|
||||
case 0:
|
||||
execv(options.mysqld_path, options.argv);
|
||||
/* exec never returns */
|
||||
@ -215,8 +214,8 @@ void Instance::fork_and_monitor()
|
||||
{
|
||||
log_info("starting instance %s", options.instance_name);
|
||||
|
||||
int result= launch_and_wait();
|
||||
if (result == -1) return;
|
||||
if (launch_and_wait())
|
||||
return; /* error is logged */
|
||||
|
||||
/* set instance state to crashed */
|
||||
pthread_mutex_lock(&LOCK_instance);
|
||||
@ -233,9 +232,6 @@ void Instance::fork_and_monitor()
|
||||
pthread_cond_signal(&instance_map->guardian->COND_guardian);
|
||||
/* thread exits */
|
||||
return;
|
||||
|
||||
/* we should never end up here */
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
|
||||
|
||||
@ -268,9 +264,9 @@ bool Instance::is_running()
|
||||
MYSQL mysql;
|
||||
uint port= 0;
|
||||
const char *socket= NULL;
|
||||
const char *password= "check_connection";
|
||||
const char *username= "MySQL_Instance_Manager";
|
||||
const char *access_denied_message= "Access denied for user";
|
||||
static const char *password= "check_connection";
|
||||
static const char *username= "MySQL_Instance_Manager";
|
||||
static const char *access_denied_message= "Access denied for user";
|
||||
bool return_val;
|
||||
|
||||
if (options.mysqld_port)
|
||||
@ -299,15 +295,8 @@ bool Instance::is_running()
|
||||
return_val= TRUE; /* server is alive */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strncmp(access_denied_message, mysql_error(&mysql),
|
||||
sizeof(access_denied_message)-1))
|
||||
{
|
||||
return_val= TRUE;
|
||||
}
|
||||
else
|
||||
return_val= FALSE;
|
||||
}
|
||||
return_val= test(!strncmp(access_denied_message, mysql_error(&mysql),
|
||||
sizeof(access_denied_message) - 1));
|
||||
|
||||
mysql_close(&mysql);
|
||||
pthread_mutex_unlock(&LOCK_instance);
|
||||
|
@ -273,8 +273,8 @@ int Listener_thread::create_tcp_socket()
|
||||
}
|
||||
|
||||
#ifndef __WIN__
|
||||
int Listener_thread::create_unix_socket(
|
||||
struct sockaddr_un &unix_socket_address)
|
||||
int Listener_thread::create_unix_socket(struct sockaddr_un
|
||||
&unix_socket_address)
|
||||
{
|
||||
int unix_socket= socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
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 */
|
||||
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;
|
||||
FD_SET(unix_socket, &read_fds);
|
||||
return 0;
|
||||
|
@ -112,11 +112,12 @@ static struct my_option my_long_options[] =
|
||||
|
||||
{ "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL"
|
||||
" 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 },
|
||||
|
||||
{ "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor instances"
|
||||
" in seconds.",
|
||||
{ "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor"
|
||||
" instances in seconds.",
|
||||
(gptr *) &Options::monitoring_interval,
|
||||
(gptr *) &Options::monitoring_interval,
|
||||
0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,
|
||||
|
@ -25,6 +25,12 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#ifdef __WIN__
|
||||
#define NEWLINE_LEN 2
|
||||
#else
|
||||
#define NEWLINE_LEN 1
|
||||
#endif
|
||||
|
||||
struct User
|
||||
{
|
||||
char user[USERNAME_LENGTH + 1];
|
||||
@ -36,8 +42,7 @@ struct User
|
||||
|
||||
int User::init(const char *line)
|
||||
{
|
||||
const char *name_begin, *name_end;
|
||||
char *password;
|
||||
const char *name_begin, *name_end, *password;
|
||||
|
||||
if (line[0] == '\'' || line[0] == '"')
|
||||
{
|
||||
@ -45,7 +50,7 @@ int User::init(const char *line)
|
||||
name_end= strchr(name_begin, line[0]);
|
||||
if (name_end == 0 || name_end[1] != ':')
|
||||
goto err;
|
||||
password= (char*)(name_end + 2);
|
||||
password= name_end + 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -53,19 +58,14 @@ int User::init(const char *line)
|
||||
name_end= strchr(name_begin, ':');
|
||||
if (name_end == 0)
|
||||
goto err;
|
||||
password= (char*)(name_end + 1);
|
||||
password= name_end + 1;
|
||||
}
|
||||
user_length= name_end - name_begin;
|
||||
if (user_length > USERNAME_LENGTH)
|
||||
goto err;
|
||||
|
||||
/* assume that newline characater is present */
|
||||
if (password[strlen(password)-2] == '\r')
|
||||
{
|
||||
password[strlen(password)-2]= '\n';
|
||||
password[strlen(password)-1]= 0;
|
||||
}
|
||||
if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + 1)
|
||||
if (strlen(password) != SCRAMBLED_PASSWORD_CHAR_LENGTH + NEWLINE_LEN)
|
||||
goto err;
|
||||
|
||||
memcpy(user, name_begin, user_length);
|
||||
|
Reference in New Issue
Block a user