]> granicus.if.org Git - icinga2/commitdiff
Gracefully deactivate all dynamic objects before shutting down.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 7 Aug 2012 11:08:14 +0000 (13:08 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 7 Aug 2012 11:08:14 +0000 (13:08 +0200)
base/application.cpp
base/dynamicobject.cpp
base/dynamicobject.h

index 54d7d348702bb2990f4be377afa51bc3dea554dc..f42f573cd8acfbab9c7c972a5c64388e93965783 100644 (file)
@@ -59,6 +59,8 @@ Application::~Application(void)
 {
        m_ShuttingDown = true;
 
+       DynamicObject::DeactivateObjects();
+
 #ifdef _WIN32
        WSACleanup();
 #endif /* _WIN32 */
index d6970f09bdc89225bf52e45fb6035fbe8faccbfa..1995808ad2bf69dcf2c9df59a7e91cc77bed9ae5 100644 (file)
@@ -442,6 +442,20 @@ void DynamicObject::RestoreObjects(const String& filename)
        }
 }
 
+void DynamicObject::DeactivateObjects(void)
+{
+       DynamicObject::TypeMap::iterator tt;
+       for (tt = GetAllObjects().begin(); tt != GetAllObjects().end(); tt++) {
+               DynamicObject::NameMap::iterator nt;
+
+               while ((nt = tt->second.begin()) != tt->second.end()) {
+                       DynamicObject::Ptr object = nt->second;
+
+                       object->Unregister();
+               }
+       }
+}
+
 DynamicObject::TypeMap& DynamicObject::GetAllObjects(void)
 {
        static TypeMap objects;
index 9856e9b79106468ba207f326adc5e0d811ea6a7f..7e9546058441a5c85f85215bce217a5063c30b23 100644 (file)
@@ -116,6 +116,7 @@ public:
 
        static void DumpObjects(const String& filename);
        static void RestoreObjects(const String& filename);
+       static void DeactivateObjects(void);
 
        static void RegisterClass(const String& type, Factory factory);
        static bool ClassExists(const String& type);