]> granicus.if.org Git - icinga2/commitdiff
Fix livestatus unit tests
authorGunnar Beutner <gunnar@beutner.name>
Wed, 18 Mar 2015 11:11:42 +0000 (12:11 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 18 Mar 2015 11:11:42 +0000 (12:11 +0100)
refs #8791

icinga-app/icinga.cpp
lib/config/configitem.cpp
lib/config/configitem.hpp

index 0f799c81dbf8568507fc20e6f49eb5e99570d872..af54c00ede7df5904a9c663140a23d170fc319a6 100644 (file)
@@ -472,6 +472,7 @@ int Main(void)
                        return EXIT_FAILURE;
                }
 
+               LogSeverity logLevel = Logger::GetConsoleLogSeverity();
                Logger::SetConsoleLogSeverity(LogWarning);
 
                if (vm.count("app"))
index c554136185b5a606ad2704b0a0e235c0f26ecbb7..437e34412dac32f547362e89417d5582068314fa 100644 (file)
@@ -45,6 +45,7 @@ using namespace icinga;
 boost::mutex ConfigItem::m_Mutex;
 ConfigItem::TypeMap ConfigItem::m_Items;
 ConfigItem::ItemList ConfigItem::m_UnnamedItems;
+ConfigItem::ItemList ConfigItem::m_CommittedItems;
 
 REGISTER_SCRIPTFUNCTION(commit_objects, &ConfigItem::ScriptCommit);
 
@@ -199,6 +200,11 @@ DynamicObject::Ptr ConfigItem::Commit(bool discard)
        dobj->SetName(name);
        dobj->OnConfigLoaded();
 
+       {
+               boost::mutex::scoped_lock lock(m_Mutex);
+               m_CommittedItems.push_back(this);
+       }
+
        Dictionary::Ptr persistentItem = new Dictionary();
 
        persistentItem->Set("type", GetType());
@@ -258,21 +264,19 @@ void ConfigItem::Register(void)
  */
 ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
 {
-       {
-               boost::mutex::scoped_lock lock(m_Mutex);
+       boost::mutex::scoped_lock lock(m_Mutex);
 
-               ConfigItem::TypeMap::const_iterator it = m_Items.find(type);
+       ConfigItem::TypeMap::const_iterator it = m_Items.find(type);
 
-               if (it == m_Items.end())
-                       return ConfigItem::Ptr();
+       if (it == m_Items.end())
+               return ConfigItem::Ptr();
 
-               ConfigItem::ItemMap::const_iterator it2 = it->second.find(name);
+       ConfigItem::ItemMap::const_iterator it2 = it->second.find(name);
 
-               if (it2 == it->second.end())
-                       return ConfigItem::Ptr();
+       if (it2 == it->second.end())
+               return ConfigItem::Ptr();
 
-               return it2->second;
-       }
+       return it2->second;
 }
 
 bool ConfigItem::CommitNewItems(WorkQueue& upq)
@@ -313,6 +317,11 @@ bool ConfigItem::CommitNewItems(WorkQueue& upq)
 
                std::vector<ConfigItem::Ptr> new_items;
 
+               {
+                       boost::mutex::scoped_lock lock(m_Mutex);
+                       new_items.swap(m_CommittedItems);
+               }
+
                std::set<String> types;
 
                BOOST_FOREACH(const ConfigItem::Ptr& item, new_items) {
index 34a83058518d819ef89e0cad6dbfc792865bf685..7bf413f947bca53bd2736e6ca600ba8e16c0a485 100644 (file)
@@ -92,6 +92,7 @@ private:
 
        typedef std::vector<ConfigItem::Ptr> ItemList;
        static ItemList m_UnnamedItems;
+       static ItemList m_CommittedItems;
 
        static ConfigItem::Ptr GetObjectUnlocked(const String& type,
            const String& name);