services: If a service is not started, then say so when ControlService() is called on it.

This commit is contained in:
Francois Gouget 2011-08-29 19:55:17 +02:00 committed by Alexandre Julliard
parent eafb44d4e1
commit fe3f2e3258
2 changed files with 7 additions and 7 deletions

View File

@ -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);

View File

@ -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;