Partially revert patches 45626 and 45633.
authorEric Kohl <eric.kohl@reactos.org>
Sat, 20 Feb 2010 23:10:53 +0000 (23:10 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 20 Feb 2010 23:10:53 +0000 (23:10 +0000)
Several services do not report their status to the service manager properly. Therefore we must not use any code that relies on service status information as part of the setup and boot processes as long as these issues have not been fixed. The service manager still needs to provide fake information about the service status.

svn path=/trunk/; revision=45640

reactos/base/system/services/database.c
reactos/dll/win32/syssetup/install.c

index 5930906..9c15717 100644 (file)
@@ -1054,7 +1054,7 @@ ScmStartService(PSERVICE Service, DWORD argc, LPWSTR *argv)
         {
             Group->ServicesRunning = TRUE;
         }
-        Service->Status.dwCurrentState = SERVICE_START_PENDING;
+        Service->Status.dwCurrentState = SERVICE_RUNNING;
     }
 #if 0
     else
index f2d3239..6a1a1f7 100644 (file)
@@ -473,34 +473,17 @@ InstallSysSetupInfComponents(VOID)
 static BOOL
 EnableUserModePnpManager(VOID)
 {
-    SERVICE_STATUS_PROCESS ServiceStatus;
     SC_HANDLE hSCManager = NULL;
     SC_HANDLE hService = NULL;
-    DWORD dwStartTickCount;
-    DWORD dwOldCheckPoint;
-    DWORD BytesNeeded = 0;
-    DWORD dwWaitTime;
-    DWORD dwMaxWait;
-    HANDLE hEvent;
     BOOL ret = FALSE;
 
-    hEvent = OpenEventW(EVENT_ALL_ACCESS,
-                        FALSE,
-                        L"SC_AutoStartComplete");
-    if (hEvent == NULL)
-        goto cleanup;
-
-    WaitForSingleObject(hEvent, INFINITE);
-
-    hSCManager = OpenSCManager(NULL,
-                               NULL,
-                               SC_MANAGER_CONNECT);
+    hSCManager = OpenSCManager(NULL, NULL, 0);
     if (hSCManager == NULL)
         goto cleanup;
 
     hService = OpenServiceW(hSCManager,
                             L"PlugPlay",
-                            SERVICE_CHANGE_CONFIG | SERVICE_START | SERVICE_QUERY_STATUS);
+                            SERVICE_CHANGE_CONFIG | SERVICE_START);
     if (hService == NULL)
         goto cleanup;
 
@@ -514,70 +497,10 @@ EnableUserModePnpManager(VOID)
         goto cleanup;
 
     ret = StartServiceW(hService, 0, NULL);
-    if (!ret)
-    {
-        /* If the service is already running, just return TRUE */
-        ret = GetLastError() == ERROR_SERVICE_ALREADY_RUNNING;
-        goto cleanup;
-    }
-
-    ret = QueryServiceStatusEx(hService,
-                               SC_STATUS_PROCESS_INFO,
-                               (LPBYTE)&ServiceStatus,
-                               sizeof(SERVICE_STATUS_PROCESS),
-                               &BytesNeeded);
     if (!ret)
         goto cleanup;
 
-    /* We don't want to wait for more than 30 seconds */
-    dwMaxWait = 30000;
-    dwStartTickCount = GetTickCount();
-
-    /* Loop until it's running */
-    while (ServiceStatus.dwCurrentState != SERVICE_RUNNING)
-    {
-        dwOldCheckPoint = ServiceStatus.dwCheckPoint;
-        dwWaitTime = ServiceStatus.dwWaitHint / 10;
-
-        /* Get the latest status info */
-        if (!QueryServiceStatusEx(hService,
-                                  SC_STATUS_PROCESS_INFO,
-                                  (LPBYTE)&ServiceStatus,
-                                  sizeof(SERVICE_STATUS_PROCESS),
-                                  &BytesNeeded))
-        {
-            /* Something went wrong... */
-            break;
-        }
-
-        /* Is the service making progress? */
-        if (ServiceStatus.dwCheckPoint > dwOldCheckPoint)
-        {
-            /* It is, get the latest tickcount to reset the max wait time */
-            dwStartTickCount = GetTickCount();
-            dwOldCheckPoint = ServiceStatus.dwCheckPoint;
-        }
-        else
-        {
-            /* It's not, make sure we haven't exceeded our wait time */
-            if (GetTickCount() >= dwStartTickCount + dwMaxWait)
-            {
-                /* We have, give up */
-                break;
-            }
-        }
-
-        /* Adjust the wait hint times */
-        if (dwWaitTime < 200)
-            dwWaitTime = 200;
-        else if (dwWaitTime > 10000)
-            dwWaitTime = 10000;
-
-        /* Wait before trying again */
-        Sleep(dwWaitTime);
-    }
-
-    ret = ServiceStatus.dwCurrentState == SERVICE_RUNNING;
+    ret = TRUE;
 
 cleanup:
     if (hSCManager != NULL)