Author: ekohl Date: Sun Apr 8 21:06:32 2012 New Revision: 56337
URL: http://svn.reactos.org/svn/reactos?rev=56337&view=rev Log: [SERVICES] - Make the handle to the shutdown event a global handle and set it when the service manager is being shut down. - Close the start event properly.
Modified: trunk/reactos/base/system/services/services.c
Modified: trunk/reactos/base/system/services/services.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servic... ============================================================================== --- trunk/reactos/base/system/services/services.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/services.c [iso-8859-1] Sun Apr 8 21:06:32 2012 @@ -27,6 +27,7 @@ #define PIPE_TIMEOUT 1000
BOOL ScmShutdown = FALSE; +static HANDLE hScmShutdownEvent = NULL;
/* FUNCTIONS *****************************************************************/ @@ -358,6 +359,9 @@
ScmAutoShutdownServices(); ScmShutdownServiceDatabase(); + + /* Set the shutdwon event */ + SetEvent(hScmShutdownEvent); }
return TRUE; @@ -371,7 +375,6 @@ int nShowCmd) { HANDLE hScmStartEvent; - HANDLE hEvent; DWORD dwError;
DPRINT("SERVICES: Service Control Manager\n"); @@ -395,6 +398,7 @@ if (dwError != ERROR_SUCCESS) { DPRINT1("SERVICES: failed to create SCM database (Error %lu)\n", dwError); + CloseHandle(hScmStartEvent); ExitThread(0); }
@@ -431,19 +435,17 @@
DPRINT("SERVICES: Running.\n");
-#if 1 - hEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - if (hEvent) - WaitForSingleObject(hEvent, INFINITE); -#else - for (;;) - { - NtYieldExecution(); - } -#endif + /* Create the shutdown event and wait until it gets set */ + hScmShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (hScmShutdownEvent) + WaitForSingleObject(hScmShutdownEvent, INFINITE);
ScmDeleteNamedPipeCriticalSection();
+ /* Close the shutdown event */ + CloseHandle(hScmShutdownEvent); + + /* Close the start event */ CloseHandle(hScmStartEvent);
DPRINT("SERVICES: Finished.\n");