Author: fireball
Date: Sun Feb 27 23:07:04 2011
New Revision: 50930

URL: http://svn.reactos.org/svn/reactos?rev=50930&view=rev
Log:
[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.

Modified:
    trunk/reactos/base/system/services/database.c

Modified: trunk/reactos/base/system/services/database.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/database.c?rev=50930&r1=50929&r2=50930&view=diff
==============================================================================
--- trunk/reactos/base/system/services/database.c [iso-8859-1] (original)
+++ trunk/reactos/base/system/services/database.c [iso-8859-1] Sun Feb 27 
23:07:04 2011
@@ -922,8 +922,6 @@
         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 @@
     if (Service->ControlPipeHandle == INVALID_HANDLE_VALUE)
     {
         DPRINT1("Failed to create control pipe!\n");
-        LeaveCriticalSection(&StartServiceCriticalSection);
         return GetLastError();
     }
 
@@ -970,7 +967,6 @@
         Service->ControlPipeHandle = INVALID_HANDLE_VALUE;
 
         DPRINT1("Starting '%S' failed!\n", Service->lpServiceName);
-        LeaveCriticalSection(&StartServiceCriticalSection);
         return dwError;
     }
 
@@ -1030,8 +1026,6 @@
     CloseHandle(ProcessInformation.hThread);
     CloseHandle(ProcessInformation.hProcess);
 
-    LeaveCriticalSection(&StartServiceCriticalSection);
-
     return dwError;
 }
 
@@ -1041,6 +1035,8 @@
 {
     PSERVICE_GROUP Group = Service->lpGroup;
     DWORD dwError = ERROR_SUCCESS;
+
+    EnterCriticalSection(&StartServiceCriticalSection);
 
     DPRINT("ScmStartService() called\n");
 
@@ -1072,6 +1068,7 @@
     }
 
     DPRINT("ScmStartService() done (Error %lu)\n", dwError);
+    LeaveCriticalSection(&StartServiceCriticalSection);
 
     if (dwError == ERROR_SUCCESS)
     {


Reply via email to