[SERVICES]
authorEric Kohl <eric.kohl@reactos.org>
Tue, 2 Aug 2011 20:37:48 +0000 (20:37 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Tue, 2 Aug 2011 20:37:48 +0000 (20:37 +0000)
- If a service will be started and another service is already running in the same image, send a start command instead of starting the process again.
This enables us to run multiple services within a single process, like svchost.exe.

svn path=/trunk/; revision=53036

reactos/base/system/services/database.c

index 462cc25..1c5dd29 100644 (file)
@@ -218,6 +218,8 @@ ScmCreateOrReferenceServiceImage(PSERVICE pService)
         pServiceImage->dwImageRunCount++;
     }
 
         pServiceImage->dwImageRunCount++;
     }
 
+    DPRINT("pServiceImage->dwImageRunCount: %lu\n", pServiceImage->dwImageRunCount);
+
     /* Link the service image to the service */
     pService->lpImage = pServiceImage;
 
     /* Link the service image to the service */
     pService->lpImage = pServiceImage;
 
@@ -1081,6 +1083,13 @@ ScmStartUserModeService(PSERVICE Service,
 
     DPRINT("ScmStartUserModeService(%p)\n", Service);
 
 
     DPRINT("ScmStartUserModeService(%p)\n", Service);
 
+    /* If the image is already running ... */
+    if (Service->lpImage->dwImageRunCount > 1)
+    {
+        /* ... just send a start command */
+        return ScmSendStartCommand(Service, argc, argv);
+    }
+
     StartupInfo.cb = sizeof(StartupInfo);
     StartupInfo.lpReserved = NULL;
     StartupInfo.lpDesktop = NULL;
     StartupInfo.cb = sizeof(StartupInfo);
     StartupInfo.lpReserved = NULL;
     StartupInfo.lpDesktop = NULL;