Author: gedmurphy
Date: Thu Sep 6 18:51:38 2007
New Revision: 28902
URL: http://svn.reactos.org/svn/reactos?rev=28902&view=rev
Log:
- Shutdown services when the SCM is terminated
- Add basic code for shutting down of the SCM
- Fix the headers
Modified:
trunk/reactos/base/system/services/config.c
trunk/reactos/base/system/services/database.c
trunk/reactos/base/system/services/driver.c
trunk/reactos/base/system/services/groupdb.c
trunk/reactos/base/system/services/rpcserver.c
trunk/reactos/base/system/services/services.c
trunk/reactos/base/system/services/services.h
Modified: trunk/reactos/base/system/services/config.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/confi…
==============================================================================
--- trunk/reactos/base/system/services/config.c (original)
+++ trunk/reactos/base/system/services/config.c Thu Sep 6 18:51:38 2007
@@ -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 *****************************************************************/
Modified: trunk/reactos/base/system/services/database.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/datab…
==============================================================================
--- trunk/reactos/base/system/services/database.c (original)
+++ trunk/reactos/base/system/services/database.c Thu Sep 6 18:51:38 2007
@@ -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(a)reactos.org>
+ * Copyright 2007 Ged Murphy <gedmurphy(a)reactos.org>
*
*/
@@ -439,6 +425,18 @@
}
+VOID
+ScmShutdownServiceDatabase(VOID)
+{
+ DPRINT("ScmShutdownServiceDatabase() called\n");
+
+ ScmDeleteMarkedServices();
+ RtlDeleteResource(&DatabaseLock);
+
+ DPRINT("ScmShutdownServiceDatabase() done\n");
+}
+
+
static NTSTATUS
ScmCheckDriver(PSERVICE Service)
{
@@ -1000,4 +998,32 @@
}
}
+
+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 */
Modified: trunk/reactos/base/system/services/driver.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/drive…
==============================================================================
--- trunk/reactos/base/system/services/driver.c (original)
+++ trunk/reactos/base/system/services/driver.c Thu Sep 6 18:51:38 2007
@@ -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 *****************************************************************/
Modified: trunk/reactos/base/system/services/groupdb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/group…
==============================================================================
--- trunk/reactos/base/system/services/groupdb.c (original)
+++ trunk/reactos/base/system/services/groupdb.c Thu Sep 6 18:51:38 2007
@@ -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 *****************************************************************/
Modified: trunk/reactos/base/system/services/rpcserver.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcse…
==============================================================================
--- trunk/reactos/base/system/services/rpcserver.c (original)
+++ trunk/reactos/base/system/services/rpcserver.c Thu Sep 6 18:51:38 2007
@@ -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(a)reactos.org>
+ * Copyright 2007 Ged Murphy <gedmurphy(a)reactos.org>
+ *
*/
/* INCLUDES ****************************************************************/
Modified: trunk/reactos/base/system/services/services.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.c (original)
+++ trunk/reactos/base/system/services/services.c Thu Sep 6 18:51:38 2007
@@ -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(a)reactos.org>
*
*/
@@ -298,7 +284,8 @@
DPRINT1("Shutdown event received!\n");
ScmShutdown = TRUE;
- /* FIXME: Shut all services down */
+ ScmAutoShutdownServices();
+ ScmShutdownServiceDatabase();
}
return TRUE;
@@ -378,6 +365,8 @@
}
#endif
+ CloseHandle(hScmStartEvent);
+
DPRINT("SERVICES: Finished.\n");
ExitThread(0);
Modified: trunk/reactos/base/system/services/services.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/servi…
==============================================================================
--- trunk/reactos/base/system/services/services.h (original)
+++ trunk/reactos/base/system/services/services.h Thu Sep 6 18:51:38 2007
@@ -94,8 +94,10 @@
/* database.c */
DWORD ScmCreateServiceDatabase(VOID);
+VOID ScmShutdownServiceDatabase(VOID);
VOID ScmGetBootAndSystemDriverState(VOID);
VOID ScmAutoStartServices(VOID);
+VOID ScmAutoShutdownServices(VOID);
DWORD ScmStartService(PSERVICE Service,
LPWSTR lpArgs);