- Shutdown services when the SCM is terminated

- Add basic code for shutting down of the SCM
- Fix the headers

svn path=/trunk/; revision=28902
This commit is contained in:
Ged Murphy 2007-09-06 14:51:38 +00:00
parent 7106e65cde
commit 2784609696
7 changed files with 85 additions and 46 deletions

View file

@ -1,5 +1,10 @@
/*
* config.c
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/config.c
* PURPOSE: Service configuration interface
* COPYRIGHT: Copyright 2005 Eric Kohl
*
*/
/* INCLUDES *****************************************************************/

View file

@ -1,25 +1,11 @@
/*
*
* service control manager
*
* ReactOS Operating System
*
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING.LIB. If not, write
* to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/database.c
* PURPOSE: Database control interface
* COPYRIGHT: Copyright 2002-2006 Eric Kohl
* Copyright 2006 Hervé Poussineau <hpoussin@reactos.org>
* Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
*
*/
@ -439,6 +425,18 @@ ScmCreateServiceDatabase(VOID)
}
VOID
ScmShutdownServiceDatabase(VOID)
{
DPRINT("ScmShutdownServiceDatabase() called\n");
ScmDeleteMarkedServices();
RtlDeleteResource(&DatabaseLock);
DPRINT("ScmShutdownServiceDatabase() done\n");
}
static NTSTATUS
ScmCheckDriver(PSERVICE Service)
{
@ -1000,4 +998,32 @@ ScmAutoStartServices(VOID)
}
}
VOID
ScmAutoShutdownServices(VOID)
{
PLIST_ENTRY ServiceEntry;
PSERVICE CurrentService;
SERVICE_STATUS ServiceStatus;
DPRINT("ScmAutoShutdownServices() called\n");
ServiceEntry = ServiceListHead.Flink;
while (ServiceEntry != &ServiceListHead)
{
CurrentService = CONTAINING_RECORD(ServiceEntry, SERVICE, ServiceListEntry);
if (CurrentService->Status.dwCurrentState == SERVICE_RUNNING ||
CurrentService->Status.dwCurrentState == SERVICE_START_PENDING)
{
/* shutdown service */
ScmControlService(CurrentService, SERVICE_CONTROL_STOP, &ServiceStatus);
}
ServiceEntry = ServiceEntry->Flink;
}
DPRINT("ScmGetBootAndSystemDriverState() done\n");
}
/* EOF */

View file

@ -1,5 +1,10 @@
/*
* driver.c
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/driver.c
* PURPOSE: Driver control interface
* COPYRIGHT: Copyright 2005-2006 Eric Kohl
*
*/
/* INCLUDES *****************************************************************/

View file

@ -1,5 +1,10 @@
/*
* groupdb.c
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/groupdb.c
* PURPOSE: Service group control interface
* COPYRIGHT: Copyright 2005 Eric Kohl
*
*/
/* INCLUDES *****************************************************************/

View file

@ -1,5 +1,12 @@
/*
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/rpcserver.c
* PURPOSE: RPC server interface for the advapi32 calls
* COPYRIGHT: Copyright 2005-2006 Eric Kohl
* Copyright 2006-2007 Hervé Poussineau <hpoussin@reactos.org>
* Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
*
*/
/* INCLUDES ****************************************************************/

View file

@ -1,24 +1,10 @@
/*
* service control manager
*
* ReactOS Operating System
*
* --------------------------------------------------------------------
*
* This software is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING.LIB. If not, write
* to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
* PROJECT: ReactOS Service Control Manager
* LICENSE: GPL - See COPYING in the top level directory
* FILE: base/system/services/services.c
* PURPOSE: Main SCM controller
* COPYRIGHT: Copyright 2001-2005 Eric Kohl
* Copyright 2007 Ged Murphy <gedmurphy@reactos.org>
*
*/
@ -298,7 +284,8 @@ ShutdownHandlerRoutine(DWORD dwCtrlType)
DPRINT1("Shutdown event received!\n");
ScmShutdown = TRUE;
/* FIXME: Shut all services down */
ScmAutoShutdownServices();
ScmShutdownServiceDatabase();
}
return TRUE;
@ -378,6 +365,8 @@ WinMain(HINSTANCE hInstance,
}
#endif
CloseHandle(hScmStartEvent);
DPRINT("SERVICES: Finished.\n");
ExitThread(0);

View file

@ -94,8 +94,10 @@ DWORD ScmReadString(HKEY hServiceKey,
/* database.c */
DWORD ScmCreateServiceDatabase(VOID);
VOID ScmShutdownServiceDatabase(VOID);
VOID ScmGetBootAndSystemDriverState(VOID);
VOID ScmAutoStartServices(VOID);
VOID ScmAutoShutdownServices(VOID);
DWORD ScmStartService(PSERVICE Service,
LPWSTR lpArgs);