[SERVICES]

- Protect whole contents of ScmStartService() with a critical section instead of just a few parts of ScmStartUserModeService(). Seems to fix the comment #8 issue of bug #5924.

svn path=/trunk/; revision=50930
This commit is contained in:
Aleksey Bragin 2011-02-27 23:07:04 +00:00
parent 27b33c3045
commit 62de69219a

View file

@ -922,8 +922,6 @@ ScmStartUserModeService(PSERVICE Service,
return Status;
}
EnterCriticalSection(&StartServiceCriticalSection);
/* Create '\\.\pipe\net\NtControlPipeXXX' instance */
swprintf(NtControlPipeName, L"\\\\.\\pipe\\net\\NtControlPipe%u", ServiceCurrent);
Service->ControlPipeHandle = CreateNamedPipeW(NtControlPipeName,
@ -938,7 +936,6 @@ ScmStartUserModeService(PSERVICE Service,
if (Service->ControlPipeHandle == INVALID_HANDLE_VALUE)
{
DPRINT1("Failed to create control pipe!\n");
LeaveCriticalSection(&StartServiceCriticalSection);
return GetLastError();
}
@ -970,7 +967,6 @@ ScmStartUserModeService(PSERVICE Service,
Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
DPRINT1("Starting '%S' failed!\n", Service->lpServiceName);
LeaveCriticalSection(&StartServiceCriticalSection);
return dwError;
}
@ -1030,8 +1026,6 @@ ScmStartUserModeService(PSERVICE Service,
CloseHandle(ProcessInformation.hThread);
CloseHandle(ProcessInformation.hProcess);
LeaveCriticalSection(&StartServiceCriticalSection);
return dwError;
}
@ -1042,6 +1036,8 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
PSERVICE_GROUP Group = Service->lpGroup;
DWORD dwError = ERROR_SUCCESS;
EnterCriticalSection(&StartServiceCriticalSection);
DPRINT("ScmStartService() called\n");
Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
@ -1072,6 +1068,7 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
}
DPRINT("ScmStartService() done (Error %lu)\n", dwError);
LeaveCriticalSection(&StartServiceCriticalSection);
if (dwError == ERROR_SUCCESS)
{