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
2f379cef
Commit
2f379cef
authored
May 08, 2002
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add several services for NT
parent
c46074f1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
27 deletions
+90
-27
sql/mysqld.cc
sql/mysqld.cc
+58
-27
sql/nt_servc.cc
sql/nt_servc.cc
+30
-0
sql/nt_servc.h
sql/nt_servc.h
+2
-0
No files found.
sql/mysqld.cc
View file @
2f379cef
...
@@ -421,6 +421,7 @@ enum db_type default_table_type=DB_TYPE_MYISAM;
...
@@ -421,6 +421,7 @@ enum db_type default_table_type=DB_TYPE_MYISAM;
#include <process.h>
#include <process.h>
#if !defined(EMBEDDED_LIBRARY)
#if !defined(EMBEDDED_LIBRARY)
HANDLE
hEventShutdown
;
HANDLE
hEventShutdown
;
static
char
*
event_name
;
#include "nt_servc.h"
#include "nt_servc.h"
static
NTService
Service
;
// Service object for WinNT
static
NTService
Service
;
// Service object for WinNT
#endif
#endif
...
@@ -2063,7 +2064,7 @@ The server will not act as a slave.");
...
@@ -2063,7 +2064,7 @@ The server will not act as a slave.");
(
void
)
thr_setconcurrency
(
concurrency
);
// 10 by default
(
void
)
thr_setconcurrency
(
concurrency
);
// 10 by default
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
#if defined(__WIN__) && !defined(EMBEDDED_LIBRARY) //IRENA
{
{
hEventShutdown
=
CreateEvent
(
0
,
FALSE
,
FALSE
,
"MySqlShutdown"
);
hEventShutdown
=
CreateEvent
(
0
,
FALSE
,
FALSE
,
event_name
);
pthread_t
hThread
;
pthread_t
hThread
;
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
if
(
pthread_create
(
&
hThread
,
&
connection_attrib
,
handle_shutdown
,
0
))
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
sql_print_error
(
"Warning: Can't create thread to handle shutdown requests"
);
...
@@ -2198,46 +2199,70 @@ int mysql_service(void *p)
...
@@ -2198,46 +2199,70 @@ int mysql_service(void *p)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
// check environment variable OS
if
(
Service
.
GetOS
())
/* true NT family */
if
(
Service
.
GetOS
())
// "OS" defined; Should be NT
{
{
char
file_path
[
FN_REFLEN
];
my_path
(
file_path
,
argv
[
0
],
""
);
/* Find name in path */
fn_format
(
file_path
,
argv
[
0
],
file_path
,
""
,
1
+
4
+
16
);
/* Force use of full path */
if
(
argc
==
2
)
if
(
argc
==
2
)
{
{
char
path
[
FN_REFLEN
];
if
(
Service
.
got_service_option
(
argv
,
"install"
))
my_path
(
path
,
argv
[
0
],
""
);
// Find name in path
fn_format
(
path
,
argv
[
0
],
path
,
""
,
1
+
4
+
16
);
// Force use of full path
if
(
!
strcmp
(
argv
[
1
],
"-install"
)
||
!
strcmp
(
argv
[
1
],
"--install"
))
{
{
Service
.
Install
(
1
,
MYSQL_SERVICENAME
,
MYSQL_SERVICENAME
,
path
);
Service
.
Install
(
1
,
MYSQL_SERVICENAME
,
MYSQL_SERVICENAME
,
file_
path
);
return
0
;
return
0
;
}
}
else
if
(
!
strcmp
(
argv
[
1
],
"-install-manual"
)
||
!
strcmp
(
argv
[
1
],
"--
install-manual"
))
else
if
(
Service
.
got_service_option
(
argv
,
"
install-manual"
))
{
{
Service
.
Install
(
0
,
MYSQL_SERVICENAME
,
MYSQL_SERVICENAME
,
path
);
Service
.
Install
(
0
,
MYSQL_SERVICENAME
,
MYSQL_SERVICENAME
,
file_
path
);
return
0
;
return
0
;
}
}
else
if
(
!
strcmp
(
argv
[
1
],
"-remove"
)
||
!
strcmp
(
argv
[
1
],
"--
remove"
))
else
if
(
Service
.
got_service_option
(
argv
,
"
remove"
))
{
{
Service
.
Remove
(
MYSQL_SERVICENAME
);
Service
.
Remove
(
MYSQL_SERVICENAME
);
return
0
;
return
0
;
}
}
else
if
(
Service
.
IsService
(
argv
[
1
]))
{
/* start an optional service */
load_default_groups
[
0
]
=
argv
[
1
];
event_name
=
argv
[
1
];
start_mode
=
1
;
Service
.
Init
(
event_name
,
mysql_service
);
return
0
;
}
}
}
else
if
(
argc
==
1
)
// No arguments; start as a service
else
if
(
argc
==
3
)
/* install or remove any optional service */
{
{
// init service
uint
length
=
strlen
(
file_path
);
start_mode
=
1
;
file_path
[
sizeof
(
file_path
)
-
1
]
=
0
;
long
tmp
=
Service
.
Init
(
MYSQL_SERVICENAME
,
mysql_service
);
strxnmov
(
file_path
+
length
,
sizeof
(
file_path
)
-
2
,
" "
,
argv
[
2
],
NullS
);
if
(
Service
.
got_service_option
(
argv
,
"install"
))
{
Service
.
Install
(
1
,
argv
[
2
],
argv
[
2
],
file_path
);
return
0
;
return
0
;
}
}
else
if
(
Service
.
got_service_option
(
argv
,
"install-manual"
))
{
Service
.
Install
(
0
,
argv
[
2
],
argv
[
2
],
file_path
);
return
0
;
}
}
else
if
(
Service
.
got_service_option
(
argv
,
"remove"
))
/*
{
This is a WIN95 machine or a start of mysqld as a standalone program
Service
.
Remove
(
argv
[
2
]);
we have to pass the arguments, in case of NT-service this will be done
return
0
;
by ServiceMain()
}
*/
}
else
if
(
argc
==
1
&&
Service
.
IsService
(
MYSQL_SERVICENAME
))
{
/* start the default service */
start_mode
=
1
;
event_name
=
"MySqlShutdown"
;
Service
.
Init
(
MYSQL_SERVICENAME
,
mysql_service
);
return
0
;
}
}
/* Start as standalone server */
Service
.
my_argc
=
argc
;
Service
.
my_argc
=
argc
;
Service
.
my_argv
=
argv
;
Service
.
my_argv
=
argv
;
mysql_service
(
NULL
);
mysql_service
(
NULL
);
...
@@ -3825,9 +3850,15 @@ Starts the MySQL server\n");
...
@@ -3825,9 +3850,15 @@ Starts the MySQL server\n");
printf
(
"Usage: %s [OPTIONS]
\n
"
,
my_progname
);
printf
(
"Usage: %s [OPTIONS]
\n
"
,
my_progname
);
#ifdef __WIN__
#ifdef __WIN__
puts
(
"NT and Win32 specific options:
\n
\
puts
(
"NT and Win32 specific options:
\n
\
--console Don't remove the console window
\n
\
--install Install the default service (NT)
\n
\
--install Install the default service (NT)
\n
\
--install-manual Install the default service started manually (NT)
\n
\
--install-manual Install the default service started manually (NT)
\n
\
--install service_name Install an optional service (NT)
\n
\
--install-manual service_name Install an optional service started manually (NT)
\n
\
--remove Remove the default service from the service list (NT)
\n
\
--remove Remove the default service from the service list (NT)
\n
\
--remove service_name Remove the service_name from the service list (NT)
\n
\
--enable-named-pipe Only to be used for the default server (NT)
\n
\
--standalone Dummy option to start as a standalone server (NT)\
"
);
"
);
puts
(
""
);
puts
(
""
);
#endif
#endif
...
...
sql/nt_servc.cc
View file @
2f379cef
...
@@ -479,3 +479,33 @@ If this condition persist, reboot the machine and try again\n");
...
@@ -479,3 +479,33 @@ If this condition persist, reboot the machine and try again\n");
return
ret_value
;
return
ret_value
;
}
}
/* ------------------------------------------------------------------------
-------------------------------------------------------------------------- */
BOOL
NTService
::
IsService
(
LPCSTR
ServiceName
)
{
BOOL
ret_value
=
FALSE
;
SC_HANDLE
service
,
scm
;
if
(
scm
=
OpenSCManager
(
0
,
0
,
SC_MANAGER_ENUMERATE_SERVICE
))
{
if
((
service
=
OpenService
(
scm
,
ServiceName
,
SERVICE_ALL_ACCESS
)))
{
ret_value
=
TRUE
;
CloseServiceHandle
(
service
);
}
CloseServiceHandle
(
scm
);
}
return
ret_value
;
}
/* ------------------------------------------------------------------------
-------------------------------------------------------------------------- */
BOOL
NTService
::
got_service_option
(
char
**
argv
,
char
*
service_option
)
{
char
*
option
=
argv
[
1
];
while
(
*
option
)
if
(
!
strcmp
(
option
++
,
service_option
))
return
TRUE
;
return
FALSE
;
}
sql/nt_servc.h
View file @
2f379cef
...
@@ -52,6 +52,8 @@ class NTService
...
@@ -52,6 +52,8 @@ class NTService
LPCSTR
szAccountName
=
NULL
,
LPCSTR
szPassword
=
NULL
);
LPCSTR
szAccountName
=
NULL
,
LPCSTR
szPassword
=
NULL
);
BOOL
SeekStatus
(
LPCSTR
szInternName
,
int
OperationType
);
BOOL
SeekStatus
(
LPCSTR
szInternName
,
int
OperationType
);
BOOL
Remove
(
LPCSTR
szInternName
);
BOOL
Remove
(
LPCSTR
szInternName
);
BOOL
IsService
(
LPCSTR
ServiceName
);
BOOL
got_service_option
(
char
**
argv
,
char
*
service_option
);
void
Stop
(
void
);
//to be called from app. to stop service
void
Stop
(
void
);
//to be called from app. to stop service
...
...
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