Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
22ccfb4d
Commit
22ccfb4d
authored
Aug 05, 2005
by
petr@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IM port cleanup
parent
07431723
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
213 additions
and
227 deletions
+213
-227
server-tools/instance-manager/IMService.cpp
server-tools/instance-manager/IMService.cpp
+5
-6
server-tools/instance-manager/WindowsService.cpp
server-tools/instance-manager/WindowsService.cpp
+42
-45
server-tools/instance-manager/WindowsService.h
server-tools/instance-manager/WindowsService.h
+4
-5
server-tools/instance-manager/instance.cc
server-tools/instance-manager/instance.cc
+86
-97
server-tools/instance-manager/listener.cc
server-tools/instance-manager/listener.cc
+24
-23
server-tools/instance-manager/manager.cc
server-tools/instance-manager/manager.cc
+11
-11
server-tools/instance-manager/options.cc
server-tools/instance-manager/options.cc
+29
-28
server-tools/instance-manager/user_map.cc
server-tools/instance-manager/user_map.cc
+12
-12
No files found.
server-tools/instance-manager/IMService.cpp
View file @
22ccfb4d
...
@@ -5,8 +5,8 @@
...
@@ -5,8 +5,8 @@
IMService
::
IMService
(
void
)
IMService
::
IMService
(
void
)
{
{
serviceName
=
"MySqlManager"
;
serviceName
=
"MySqlManager"
;
displayName
=
"MySQL Manager"
;
displayName
=
"MySQL Manager"
;
}
}
IMService
::~
IMService
(
void
)
IMService
::~
IMService
(
void
)
...
@@ -69,4 +69,3 @@ int HandleServiceOptions(Options options)
...
@@ -69,4 +69,3 @@ int HandleServiceOptions(Options options)
return
(
int
)
winService
.
Init
();
return
(
int
)
winService
.
Init
();
return
ret_val
;
return
ret_val
;
}
}
server-tools/instance-manager/WindowsService.cpp
View file @
22ccfb4d
...
@@ -155,8 +155,7 @@ void WindowsService::RegisterAndRun(DWORD argc, LPTSTR *argv)
...
@@ -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)
...
@@ -201,5 +200,3 @@ void WINAPI WindowsService::ControlHandler(DWORD opcode)
return
gService
->
HandleControlCode
(
opcode
);
return
gService
->
HandleControlCode
(
opcode
);
}
}
server-tools/instance-manager/WindowsService.h
View file @
22ccfb4d
...
@@ -23,7 +23,7 @@ class WindowsService
...
@@ -23,7 +23,7 @@ class WindowsService
BOOL
Init
();
BOOL
Init
();
BOOL
IsInstalled
();
BOOL
IsInstalled
();
void
SetAcceptedControls
(
DWORD
acceptedControls
);
void
SetAcceptedControls
(
DWORD
acceptedControls
);
void
Debug
(
bool
debugFlag
)
{
debugging
=
debugFlag
;
}
void
Debug
(
bool
debugFlag
)
{
debugging
=
debugFlag
;
}
public:
public:
static
void
WINAPI
ServiceMain
(
DWORD
argc
,
LPTSTR
*
argv
);
static
void
WINAPI
ServiceMain
(
DWORD
argc
,
LPTSTR
*
argv
);
...
@@ -41,4 +41,3 @@ class WindowsService
...
@@ -41,4 +41,3 @@ class WindowsService
void
HandleControlCode
(
DWORD
opcode
);
void
HandleControlCode
(
DWORD
opcode
);
void
RegisterAndRun
(
DWORD
argc
,
LPTSTR
*
argv
);
void
RegisterAndRun
(
DWORD
argc
,
LPTSTR
*
argv
);
};
};
server-tools/instance-manager/instance.cc
View file @
22ccfb4d
...
@@ -121,8 +121,7 @@ int Instance::launch_and_wait()
...
@@ -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 */
...
@@ -161,7 +160,7 @@ int Instance::launch_and_wait()
...
@@ -161,7 +160,7 @@ int Instance::launch_and_wait()
PROCESS_INFORMATION
pi
;
PROCESS_INFORMATION
pi
;
ZeroMemory
(
&
si
,
sizeof
(
si
));
ZeroMemory
(
&
si
,
sizeof
(
si
));
si
.
cb
=
sizeof
(
si
);
si
.
cb
=
sizeof
(
si
);
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
ZeroMemory
(
&
pi
,
sizeof
(
pi
));
int
cmdlen
=
0
;
int
cmdlen
=
0
;
...
@@ -215,8 +214,8 @@ void Instance::fork_and_monitor()
...
@@ -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
);
i
nt
result
=
launch_and_wait
();
i
f
(
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()
...
@@ -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()
...
@@ -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()
...
@@ -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
);
...
@@ -370,7 +359,7 @@ int Instance::stop()
...
@@ -370,7 +359,7 @@ int Instance::stop()
BOOL
SafeTerminateProcess
(
HANDLE
hProcess
,
UINT
uExitCode
)
BOOL
SafeTerminateProcess
(
HANDLE
hProcess
,
UINT
uExitCode
)
{
{
DWORD
dwTID
,
dwCode
,
dwErr
=
0
;
DWORD
dwTID
,
dwCode
,
dwErr
=
0
;
HANDLE
hProcessDup
=
INVALID_HANDLE_VALUE
;
HANDLE
hProcessDup
=
INVALID_HANDLE_VALUE
;
HANDLE
hRT
=
NULL
;
HANDLE
hRT
=
NULL
;
HINSTANCE
hKernel
=
GetModuleHandle
(
"Kernel32"
);
HINSTANCE
hKernel
=
GetModuleHandle
(
"Kernel32"
);
...
...
server-tools/instance-manager/listener.cc
View file @
22ccfb4d
...
@@ -150,7 +150,7 @@ void Listener_thread::run()
...
@@ -150,7 +150,7 @@ void Listener_thread::run()
/* accept may return -1 (failure or spurious wakeup) */
/* accept may return -1 (failure or spurious wakeup) */
if
(
client_fd
>=
0
)
// connection established
if
(
client_fd
>=
0
)
// connection established
{
{
Vio
*
vio
=
vio_new
(
client_fd
,
socket_index
==
0
?
VIO_TYPE_SOCKET
:
Vio
*
vio
=
vio_new
(
client_fd
,
socket_index
==
0
?
VIO_TYPE_SOCKET
:
VIO_TYPE_TCPIP
,
socket_index
==
0
?
1
:
0
);
VIO_TYPE_TCPIP
,
socket_index
==
0
?
1
:
0
);
if
(
vio
!=
0
)
if
(
vio
!=
0
)
handle_new_mysql_connection
(
vio
);
handle_new_mysql_connection
(
vio
);
...
@@ -236,7 +236,7 @@ int Listener_thread::create_tcp_socket()
...
@@ -236,7 +236,7 @@ int Listener_thread::create_tcp_socket()
uint
im_port
=
options
.
port_number
;
uint
im_port
=
options
.
port_number
;
ip_socket_address
.
sin_family
=
AF_INET
;
ip_socket_address
.
sin_family
=
AF_INET
;
ip_socket_address
.
sin_addr
.
s_addr
=
im_bind_addr
;
ip_socket_address
.
sin_addr
.
s_addr
=
im_bind_addr
;
ip_socket_address
.
sin_port
=
(
unsigned
short
)
ip_socket_address
.
sin_port
=
(
unsigned
short
)
...
@@ -273,8 +273,8 @@ int Listener_thread::create_tcp_socket()
...
@@ -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,8 +322,9 @@ int Listener_thread::create_unix_socket(
...
@@ -322,8 +322,9 @@ 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"
,
sockets
[
num_sockets
++
]
=
unix_socket
;
unix_socket_address
.
sun_path
);
sockets
[
num_sockets
++
]
=
unix_socket
;
FD_SET
(
unix_socket
,
&
read_fds
);
FD_SET
(
unix_socket
,
&
read_fds
);
return
0
;
return
0
;
}
}
...
...
server-tools/instance-manager/manager.cc
View file @
22ccfb4d
server-tools/instance-manager/options.cc
View file @
22ccfb4d
...
@@ -112,11 +112,12 @@ static struct my_option my_long_options[] =
...
@@ -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
,
...
@@ -327,9 +328,9 @@ char* change_extension(const char *src, const char *newext)
...
@@ -327,9 +328,9 @@ char* change_extension(const char *src, const char *newext)
void
Options
::
setup_windows_defaults
(
const
char
*
progname
)
void
Options
::
setup_windows_defaults
(
const
char
*
progname
)
{
{
Options
::
password_file_name
=
default_password_file_name
=
Options
::
password_file_name
=
default_password_file_name
=
change_extension
(
progname
,
"passwd"
);
change_extension
(
progname
,
"passwd"
);
Options
::
log_file_name
=
default_log_file_name
=
Options
::
log_file_name
=
default_log_file_name
=
change_extension
(
progname
,
"log"
);
change_extension
(
progname
,
"log"
);
}
}
...
...
server-tools/instance-manager/user_map.cc
View file @
22ccfb4d
...
@@ -25,6 +25,12 @@
...
@@ -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
...
@@ -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)
...
@@ -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)
...
@@ -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
);
...
@@ -101,7 +101,7 @@ C_MODE_END
...
@@ -101,7 +101,7 @@ C_MODE_END
int
User_map
::
init
()
int
User_map
::
init
()
{
{
enum
{
START_HASH_SIZE
=
16
};
enum
{
START_HASH_SIZE
=
16
};
if
(
hash_init
(
&
hash
,
default_charset_info
,
START_HASH_SIZE
,
0
,
0
,
if
(
hash_init
(
&
hash
,
default_charset_info
,
START_HASH_SIZE
,
0
,
0
,
get_user_key
,
delete_user
,
0
))
get_user_key
,
delete_user
,
0
))
return
1
;
return
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment