Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
a631ee1e
Commit
a631ee1e
authored
Oct 05, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Service code refactored
parent
493666da
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
main.c
build/main.c
+8
-12
No files found.
build/main.c
View file @
a631ee1e
...
...
@@ -414,32 +414,29 @@ static HICON hIcon;
static
SERVICE_STATUS
ss
;
static
SERVICE_STATUS_HANDLE
hStatus
;
static
const
char
*
service_magic_argument
=
"--"
;
static
const
char
*
service_name
=
"Mongoose"
;
static
NOTIFYICONDATA
TrayIcon
;
static
void
WINAPI
ControlHandler
(
DWORD
code
)
{
ss
.
dwControlsAccepted
=
SERVICE_ACCEPT_STOP
|
SERVICE_ACCEPT_SHUTDOWN
;
ss
.
dwServiceType
=
SERVICE_WIN32
;
ss
.
dwWin32ExitCode
=
NO_ERROR
;
ss
.
dwCurrentState
=
SERVICE_RUNNING
;
if
(
code
==
SERVICE_CONTROL_STOP
||
code
==
SERVICE_CONTROL_SHUTDOWN
)
{
ss
.
dwWin32ExitCode
=
0
;
ss
.
dwCurrentState
=
SERVICE_STOPPED
;
}
SetServiceStatus
(
hStatus
,
&
ss
);
}
static
void
WINAPI
ServiceMain
(
void
)
{
ss
.
dwServiceType
=
SERVICE_WIN32
;
ss
.
dwCurrentState
=
SERVICE_RUNNING
;
ss
.
dwControlsAccepted
=
SERVICE_ACCEPT_STOP
|
SERVICE_ACCEPT_SHUTDOWN
;
hStatus
=
RegisterServiceCtrlHandler
(
server_name
,
ControlHandler
);
SetServiceStatus
(
hStatus
,
&
ss
);
hStatus
=
RegisterServiceCtrlHandler
(
service_name
,
ControlHandler
);
ControlHandler
(
SERVICE_CONTROL_INTERROGATE
);
while
(
ss
.
dwCurrentState
==
SERVICE_RUNNING
)
{
Sleep
(
1000
);
}
mg_stop
(
ctx
);
ss
.
dwCurrentState
=
SERVICE_STOPPED
;
ss
.
dwWin32ExitCode
=
(
DWORD
)
-
1
;
SetServiceStatus
(
hStatus
,
&
ss
);
}
...
...
@@ -719,7 +716,6 @@ static void show_settings_dialog() {
}
static
int
manage_service
(
int
action
)
{
static
const
char
*
service_name
=
"Mongoose"
;
SC_HANDLE
hSCM
=
NULL
,
hService
=
NULL
;
SERVICE_DESCRIPTION
descr
=
{
server_name
};
char
path
[
PATH_MAX
+
20
];
// Path to executable plus magic argument
...
...
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