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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
31be8fb6
Commit
31be8fb6
authored
Sep 13, 2005
by
reggie@ubuntu.(none)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed the service bits of the IM
parent
6985adff
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
58 additions
and
31 deletions
+58
-31
server-tools/instance-manager/IMService.cpp
server-tools/instance-manager/IMService.cpp
+12
-1
server-tools/instance-manager/IMService.h
server-tools/instance-manager/IMService.h
+1
-1
server-tools/instance-manager/WindowsService.cpp
server-tools/instance-manager/WindowsService.cpp
+3
-2
server-tools/instance-manager/WindowsService.h
server-tools/instance-manager/WindowsService.h
+1
-1
server-tools/instance-manager/instance.cc
server-tools/instance-manager/instance.cc
+12
-16
server-tools/instance-manager/instance_options.cc
server-tools/instance-manager/instance_options.cc
+8
-0
server-tools/instance-manager/listener.cc
server-tools/instance-manager/listener.cc
+8
-5
server-tools/instance-manager/mysqlmanager.cc
server-tools/instance-manager/mysqlmanager.cc
+6
-4
server-tools/instance-manager/options.cc
server-tools/instance-manager/options.cc
+5
-0
server-tools/instance-manager/options.h
server-tools/instance-manager/options.h
+2
-1
No files found.
server-tools/instance-manager/IMService.cpp
View file @
31be8fb6
#include <windows.h>
#include <signal.h>
#include "log.h"
#include "options.h"
#include "IMService.h"
#include "manager.h"
IMService
::
IMService
(
void
)
{
serviceName
=
"MySqlManager"
;
displayName
=
"MySQL Manager"
;
username
=
NULL
;
password
=
NULL
;
}
IMService
::~
IMService
(
void
)
...
...
@@ -16,18 +20,25 @@ IMService::~IMService(void)
void
IMService
::
Stop
()
{
ReportStatus
(
SERVICE_STOP_PENDING
);
// stop the IM work
raise
(
SIGTERM
);
}
void
IMService
::
Run
()
void
IMService
::
Run
(
DWORD
argc
,
LPTSTR
*
argv
)
{
// report to the SCM that we're about to start
ReportStatus
((
DWORD
)
SERVICE_START_PENDING
);
Options
o
;
o
.
load
(
argc
,
argv
);
// init goes here
ReportStatus
((
DWORD
)
SERVICE_RUNNING
);
// wait for main loop to terminate
manager
(
o
);
o
.
cleanup
();
}
void
IMService
::
Log
(
const
char
*
msg
)
...
...
server-tools/instance-manager/IMService.h
View file @
31be8fb6
...
...
@@ -10,5 +10,5 @@ public:
protected:
void
Log
(
const
char
*
msg
);
void
Stop
();
void
Run
();
void
Run
(
DWORD
argc
,
LPTSTR
*
argv
);
};
server-tools/instance-manager/WindowsService.cpp
View file @
31be8fb6
...
...
@@ -8,7 +8,8 @@ WindowsService::WindowsService(void) :
statusCheckpoint
(
0
),
serviceName
(
NULL
),
inited
(
false
),
dwAcceptedControls
(
SERVICE_ACCEPT_STOP
)
dwAcceptedControls
(
SERVICE_ACCEPT_STOP
),
debugging
(
false
)
{
gService
=
this
;
status
.
dwServiceType
=
SERVICE_WIN32_OWN_PROCESS
;
...
...
@@ -148,7 +149,7 @@ void WindowsService::RegisterAndRun(DWORD argc, LPTSTR *argv)
{
statusHandle
=
::
RegisterServiceCtrlHandler
(
serviceName
,
ControlHandler
);
if
(
statusHandle
&&
ReportStatus
(
SERVICE_START_PENDING
))
Run
();
Run
(
argc
,
argv
);
ReportStatus
(
SERVICE_STOPPED
);
}
...
...
server-tools/instance-manager/WindowsService.h
View file @
31be8fb6
...
...
@@ -30,7 +30,7 @@ public:
static
void
WINAPI
ControlHandler
(
DWORD
CtrlType
);
protected:
virtual
void
Run
()
=
0
;
virtual
void
Run
(
DWORD
argc
,
LPTSTR
*
argv
)
=
0
;
virtual
void
Stop
()
{}
virtual
void
Shutdown
()
{}
virtual
void
Pause
()
{}
...
...
server-tools/instance-manager/instance.cc
View file @
31be8fb6
...
...
@@ -18,9 +18,6 @@
#pragma implementation
#endif
#ifdef __WIN__
#include <process.h>
#endif
#include "instance.h"
#include "mysql_manager_error.h"
...
...
@@ -171,25 +168,24 @@ static int start_process(Instance_options *instance_options,
ZeroMemory
(
pi
,
sizeof
(
PROCESS_INFORMATION
));
int
cmdlen
=
0
;
for
(
int
i
=
1
;
instance_options
->
argv
[
i
]
!=
0
;
i
++
)
cmdlen
+=
strlen
(
instance_options
->
argv
[
i
])
+
1
;
cmdlen
++
;
/* we have to add a single space for CreateProcess (see docs) */
for
(
int
i
=
0
;
instance_options
->
argv
[
i
]
!=
0
;
i
++
)
cmdlen
+=
strlen
(
instance_options
->
argv
[
i
])
+
3
;
cmdlen
++
;
/* make room for the null */
char
*
cmdline
=
new
char
[
cmdlen
];
if
(
cmdline
==
NULL
)
return
1
;
char
*
cmdline
=
NULL
;
if
(
cmdlen
>
0
)
for
(
int
i
=
0
;
instance_options
->
argv
[
i
]
!=
0
;
i
++
)
{
cmdline
=
new
char
[
cmdlen
];
cmdline
[
0
]
=
0
;
for
(
int
i
=
1
;
instance_options
->
argv
[
i
]
!=
0
;
i
++
)
{
strcat
(
cmdline
,
" "
);
strcat
(
cmdline
,
instance_options
->
argv
[
i
]);
}
strcat
(
cmdline
,
"
\"
"
);
strcat
(
cmdline
,
instance_options
->
argv
[
i
]);
strcat
(
cmdline
,
"
\"
"
);
}
/* Start the child process */
BOOL
result
=
CreateProcess
(
instance_options
->
mysqld_path
,
/* File to execut
e */
CreateProcess
(
NULL
,
/* Put it all in cmdlin
e */
cmdline
,
/* Command line */
NULL
,
/* Process handle not inheritable */
NULL
,
/* Thread handle not inheritable */
...
...
server-tools/instance-manager/instance_options.cc
View file @
31be8fb6
...
...
@@ -46,8 +46,16 @@ static inline int create_mysqld_command(Buffer *buf,
if
(
buf
->
get_size
())
/* malloc succeeded */
{
#ifdef __WIN__
buf
->
append
(
position
,
"
\"
"
,
1
);
position
++
;
#endif
buf
->
append
(
position
,
mysqld_path_str
,
mysqld_path_len
);
position
+=
mysqld_path_len
;
#ifdef __WIN__
buf
->
append
(
position
,
"
\"
"
,
1
);
position
++
;
#endif
/* here the '\0' character is copied from the option string */
buf
->
append
(
position
,
option
,
option_len
);
...
...
server-tools/instance-manager/listener.cc
View file @
31be8fb6
...
...
@@ -121,6 +121,9 @@ void Listener_thread::run()
n
=
max
(
n
,
sockets
[
i
]);
n
++
;
timeval
tv
;
tv
.
tv_sec
=
0
;
tv
.
tv_usec
=
100000
;
while
(
!
thread_registry
.
is_shutdown
())
{
fd_set
read_fds_arg
=
read_fds
;
...
...
@@ -130,13 +133,13 @@ void Listener_thread::run()
signal during shutdown. This results in failing assert
(Thread_registry::~Thread_registry). Valgrind 2.2 works fine.
*/
int
rc
=
select
(
n
,
&
read_fds_arg
,
0
,
0
,
0
);
int
rc
=
select
(
n
,
&
read_fds_arg
,
0
,
0
,
&
tv
);
if
(
rc
==
-
1
&&
errno
!=
EINTR
)
if
(
rc
==
0
||
rc
==
-
1
)
{
log_error
(
"Listener_thread::run(): select() failed, %s"
,
strerror
(
errno
));
if
(
rc
==
-
1
&&
errno
!=
EINTR
)
log_error
(
"Listener_thread::run(): select() failed, %s"
,
strerror
(
errno
));
continue
;
}
...
...
server-tools/instance-manager/mysqlmanager.cc
View file @
31be8fb6
...
...
@@ -102,10 +102,12 @@ int main(int argc, char *argv[])
angel
(
options
);
}
#else
#ifdef NDEBUG
return_value
=
HandleServiceOptions
(
options
);
goto
err
;
/* this is not always an error but we reuse the label */
#endif
if
(
!
options
.
stand_alone
)
{
if
(
HandleServiceOptions
(
options
))
goto
err
;
}
else
#endif
manager
(
options
);
...
...
server-tools/instance-manager/options.cc
View file @
31be8fb6
...
...
@@ -33,6 +33,7 @@
#ifdef __WIN__
char
Options
::
install_as_service
;
char
Options
::
remove_service
;
char
Options
::
stand_alone
;
char
windows_config_file
[
FN_REFLEN
];
char
default_password_file_name
[
FN_REFLEN
];
char
default_log_file_name
[
FN_REFLEN
];
...
...
@@ -72,6 +73,7 @@ enum options {
#else
OPT_INSTALL_SERVICE
,
OPT_REMOVE_SERVICE
,
OPT_STAND_ALONE
,
#endif
OPT_MONITORING_INTERVAL
,
OPT_PORT
,
...
...
@@ -131,6 +133,9 @@ static struct my_option my_long_options[] =
{
"remove"
,
OPT_REMOVE_SERVICE
,
"Remove system service."
,
(
gptr
*
)
&
Options
::
remove_service
,
(
gptr
*
)
&
Options
::
remove_service
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
1
,
0
,
0
,
0
},
{
"standalone"
,
OPT_STAND_ALONE
,
"Run the application in stand alone mode."
,
(
gptr
*
)
&
Options
::
stand_alone
,
(
gptr
*
)
&
Options
::
stand_alone
,
0
,
GET_BOOL
,
NO_ARG
,
0
,
0
,
1
,
0
,
0
,
0
},
#else
{
"run-as-service"
,
OPT_RUN_AS_SERVICE
,
"Daemonize and start angel process."
,
(
gptr
*
)
&
Options
::
run_as_service
,
...
...
server-tools/instance-manager/options.h
View file @
31be8fb6
...
...
@@ -31,6 +31,7 @@ struct Options
#ifdef __WIN__
static
char
install_as_service
;
static
char
remove_service
;
static
char
stand_alone
;
#else
static
char
run_as_service
;
/* handle_options doesn't support bool */
static
const
char
*
user
;
...
...
@@ -52,7 +53,7 @@ struct Options
int
load
(
int
argc
,
char
**
argv
);
void
cleanup
();
#ifdef __WIN__
int
setup_windows_defaults
(
const
char
*
progname
);
int
setup_windows_defaults
();
#endif
};
...
...
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