[3/3] services: If a service is not started, then say so when ControlService() is called on it.
Francois Gouget
fgouget at codeweavers.com
Mon Aug 29 12:55:17 CDT 2011
---
Services that are stopped don't accept any control so we would
systematically return ERROR_INVALID_SERVICE_CONTROL. So checking for the
state first makes much more sense.
dlls/advapi32/tests/service.c | 2 +-
programs/services/rpc.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/advapi32/tests/service.c b/dlls/advapi32/tests/service.c
index d2ef54d..d594416 100644
--- a/dlls/advapi32/tests/service.c
+++ b/dlls/advapi32/tests/service.c
@@ -2095,7 +2095,7 @@ static DWORD try_start_stop(SC_HANDLE svc_handle, const char* name, DWORD is_nt4
ret = ControlService(svc_handle, SERVICE_CONTROL_STOP, &status);
le2 = GetLastError();
ok(!ret, "%s: ControlService() should have failed\n", name);
- todo_wine ok(le2 == ERROR_SERVICE_NOT_ACTIVE, "%s: %d != ERROR_SERVICE_NOT_ACTIVE\n", name, le2);
+ ok(le2 == ERROR_SERVICE_NOT_ACTIVE, "%s: %d != ERROR_SERVICE_NOT_ACTIVE\n", name, le2);
ok(status.dwCurrentState == SERVICE_STOPPED ||
broken(is_nt4), /* NT4 returns a random value */
"%s: should be stopped state=%x\n", name, status.dwCurrentState);
diff --git a/programs/services/rpc.c b/programs/services/rpc.c
index 573b748..2d853c0 100644
--- a/programs/services/rpc.c
+++ b/programs/services/rpc.c
@@ -1023,12 +1023,6 @@ DWORD __cdecl svcctl_ControlService(
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint;
}
- if (!service_accepts_control(service->service_entry, dwControl))
- {
- service_unlock(service->service_entry);
- return ERROR_INVALID_SERVICE_CONTROL;
- }
-
switch (service->service_entry->status.dwCurrentState)
{
case SERVICE_STOPPED:
@@ -1043,6 +1037,12 @@ DWORD __cdecl svcctl_ControlService(
return ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
}
+ if (!service_accepts_control(service->service_entry, dwControl))
+ {
+ service_unlock(service->service_entry);
+ return ERROR_INVALID_SERVICE_CONTROL;
+ }
+
/* prevent races by caching these variables and clearing them on
* stop here instead of outside the services lock */
control_mutex = service->service_entry->control_mutex;
--
1.7.5.4
More information about the wine-patches
mailing list