Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
60a27356
Commit
60a27356
authored
Nov 30, 2011
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
services: Wait for all services to terminate before exiting.
parent
e2172edc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
services.c
programs/services/services.c
+31
-3
services.h
programs/services/services.h
+1
-0
No files found.
programs/services/services.c
View file @
60a27356
...
...
@@ -98,6 +98,7 @@ void free_service_entry(struct service_entry *entry)
HeapFree
(
GetProcessHeap
(),
0
,
entry
->
description
);
HeapFree
(
GetProcessHeap
(),
0
,
entry
->
dependOnServices
);
HeapFree
(
GetProcessHeap
(),
0
,
entry
->
dependOnGroups
);
CloseHandle
(
entry
->
process
);
CloseHandle
(
entry
->
control_mutex
);
CloseHandle
(
entry
->
control_pipe
);
CloseHandle
(
entry
->
overlapped_event
);
...
...
@@ -312,6 +313,32 @@ static void scmdatabase_autostart_services(struct scmdatabase *db)
HeapFree
(
GetProcessHeap
(),
0
,
services_list
);
}
static
void
scmdatabase_wait_terminate
(
struct
scmdatabase
*
db
)
{
struct
service_entry
*
service
;
BOOL
run
=
TRUE
;
scmdatabase_lock_shared
(
db
);
while
(
run
)
{
run
=
FALSE
;
LIST_FOR_EACH_ENTRY
(
service
,
&
db
->
services
,
struct
service_entry
,
entry
)
{
if
(
service
->
process
)
{
scmdatabase_unlock
(
db
);
WaitForSingleObject
(
service
->
process
,
INFINITE
);
scmdatabase_lock_shared
(
db
);
CloseHandle
(
service
->
process
);
service
->
process
=
NULL
;
run
=
TRUE
;
break
;
}
}
}
scmdatabase_unlock
(
db
);
}
BOOL
validate_service_name
(
LPCWSTR
name
)
{
return
(
name
&&
name
[
0
]
&&
!
strchrW
(
name
,
'/'
)
&&
!
strchrW
(
name
,
'\\'
));
...
...
@@ -662,6 +689,7 @@ static DWORD service_start_process(struct service_entry *service_entry, HANDLE *
}
service_entry
->
status
.
dwProcessId
=
pi
.
dwProcessId
;
service_entry
->
process
=
pi
.
hProcess
;
*
process
=
pi
.
hProcess
;
CloseHandle
(
pi
.
hThread
);
...
...
@@ -808,9 +836,6 @@ DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *
if
(
err
==
ERROR_SUCCESS
)
err
=
service_wait_for_startup
(
service
,
process_handle
);
if
(
process_handle
)
CloseHandle
(
process_handle
);
}
if
(
err
==
ERROR_SUCCESS
)
...
...
@@ -884,9 +909,12 @@ int main(int argc, char *argv[])
{
scmdatabase_autostart_services
(
active_database
);
RPC_MainLoop
();
scmdatabase_wait_terminate
(
active_database
);
}
scmdatabase_destroy
(
active_database
);
if
(
env
)
DestroyEnvironmentBlock
(
env
);
WINE_TRACE
(
"services.exe exited with code %d
\n
"
,
err
);
return
err
;
}
programs/services/services.h
View file @
60a27356
...
...
@@ -43,6 +43,7 @@ struct service_entry
LPWSTR
description
;
LPWSTR
dependOnServices
;
LPWSTR
dependOnGroups
;
HANDLE
process
;
HANDLE
control_mutex
;
HANDLE
control_pipe
;
HANDLE
overlapped_event
;
...
...
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