Piotr Caban : services: Don' t close control_pipe when SERVICE_CONTROL_STOP is sent.
Alexandre Julliard
julliard at winehq.org
Mon Dec 12 12:25:54 CST 2011
Module: wine
Branch: master
Commit: bc866c899f8fd68bc5602401fb2fbc5348ede2a7
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bc866c899f8fd68bc5602401fb2fbc5348ede2a7
Author: Piotr Caban <piotr at codeweavers.com>
Date: Mon Dec 12 11:04:28 2011 +0100
services: Don't close control_pipe when SERVICE_CONTROL_STOP is sent.
This prevents service_control_dispatcher from being stopped. Thanks to
it the service may continue to work and do the clean up.
---
programs/services/rpc.c | 18 ++++--------------
programs/services/services.c | 1 +
2 files changed, 5 insertions(+), 14 deletions(-)
diff --git a/programs/services/rpc.c b/programs/services/rpc.c
index 5fe8585..2337667 100644
--- a/programs/services/rpc.c
+++ b/programs/services/rpc.c
@@ -1015,7 +1015,6 @@ DWORD __cdecl svcctl_ControlService(
DWORD result;
BOOL ret;
HANDLE control_mutex;
- HANDLE control_pipe;
WINE_TRACE("(%p, %d, %p)\n", hService, dwControl, lpServiceStatus);
@@ -1085,22 +1084,19 @@ DWORD __cdecl svcctl_ControlService(
return ERROR_INVALID_SERVICE_CONTROL;
}
- /* prevent races by caching these variables and clearing them on
- * stop here instead of outside the services lock */
+ /* prevent races by caching control_mutex and clearing it on
+ * stop instead of outside the services lock */
control_mutex = service->service_entry->control_mutex;
- control_pipe = service->service_entry->control_pipe;
if (dwControl == SERVICE_CONTROL_STOP)
- {
service->service_entry->control_mutex = NULL;
- service->service_entry->control_pipe = INVALID_HANDLE_VALUE;
- }
service_unlock(service->service_entry);
ret = WaitForSingleObject(control_mutex, 30000);
if (ret == WAIT_OBJECT_0)
{
- service_send_control(service->service_entry, control_pipe, dwControl, &result);
+ service_send_control(service->service_entry, service->service_entry->control_pipe,
+ dwControl, &result);
if (lpServiceStatus)
{
@@ -1116,10 +1112,7 @@ DWORD __cdecl svcctl_ControlService(
}
if (dwControl == SERVICE_CONTROL_STOP)
- {
CloseHandle(control_mutex);
- CloseHandle(control_pipe);
- }
else
ReleaseMutex(control_mutex);
@@ -1128,10 +1121,7 @@ DWORD __cdecl svcctl_ControlService(
else
{
if (dwControl == SERVICE_CONTROL_STOP)
- {
CloseHandle(control_mutex);
- CloseHandle(control_pipe);
- }
return ERROR_SERVICE_REQUEST_TIMEOUT;
}
}
diff --git a/programs/services/services.c b/programs/services/services.c
index f2c5d26..865cb55 100644
--- a/programs/services/services.c
+++ b/programs/services/services.c
@@ -813,6 +813,7 @@ DWORD service_start(struct service_entry *service, DWORD service_argc, LPCWSTR *
return ERROR_SERVICE_ALREADY_RUNNING;
}
+ CloseHandle(service->control_pipe);
service->control_mutex = CreateMutexW(NULL, TRUE, NULL);
if (!service->status_changed_event)
More information about the wine-cvs
mailing list