Commit fe3f2e32 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

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

parent eafb44d4
...@@ -2095,7 +2095,7 @@ static DWORD try_start_stop(SC_HANDLE svc_handle, const char* name, DWORD is_nt4 ...@@ -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); ret = ControlService(svc_handle, SERVICE_CONTROL_STOP, &status);
le2 = GetLastError(); le2 = GetLastError();
ok(!ret, "%s: ControlService() should have failed\n", name); 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 || ok(status.dwCurrentState == SERVICE_STOPPED ||
broken(is_nt4), /* NT4 returns a random value */ broken(is_nt4), /* NT4 returns a random value */
"%s: should be stopped state=%x\n", name, status.dwCurrentState); "%s: should be stopped state=%x\n", name, status.dwCurrentState);
......
...@@ -1023,12 +1023,6 @@ DWORD __cdecl svcctl_ControlService( ...@@ -1023,12 +1023,6 @@ DWORD __cdecl svcctl_ControlService(
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint; 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) switch (service->service_entry->status.dwCurrentState)
{ {
case SERVICE_STOPPED: case SERVICE_STOPPED:
...@@ -1043,6 +1037,12 @@ DWORD __cdecl svcctl_ControlService( ...@@ -1043,6 +1037,12 @@ DWORD __cdecl svcctl_ControlService(
return ERROR_SERVICE_CANNOT_ACCEPT_CTRL; 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 /* prevent races by caching these variables and clearing them on
* stop here instead of outside the services lock */ * stop here instead of outside the services lock */
control_mutex = service->service_entry->control_mutex; control_mutex = service->service_entry->control_mutex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment