From: Gunnar Beutner Date: Tue, 12 Jun 2012 08:49:30 +0000 (+0200) Subject: Bugfixes. X-Git-Tag: v0.0.1~441 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0270d9cf52aa3e79a818f30678641a8017c8286e;p=icinga2 Bugfixes. --- diff --git a/base/objectmap.h b/base/objectmap.h index 6456ab4c4..2411d542e 100644 --- a/base/objectmap.h +++ b/base/objectmap.h @@ -44,11 +44,11 @@ public: void Start(void) { m_Parent->OnObjectAdded += bind_weak(&ObjectMap::ObjectAddedHandler, shared_from_this()); - m_Parent->OnObjectCommitted += bind_weak(&ObjectMap::ObjectCommittedHandler, shared_from_this()); - m_Parent->OnObjectRemoved += bind_weak(&ObjectMap::ObjectRemovedHandler, shared_from_this()); + m_Parent->OnObjectCommitted += bind_weak(&ObjectMap::ObjectCommittedHandler, shared_from_this()); + m_Parent->OnObjectRemoved += bind_weak(&ObjectMap::ObjectRemovedHandler, shared_from_this()); - for (typename ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++) - AddObject(*it); + for (typename ObjectSet::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++) + AddObject(*it); } Range GetRange(TKey key) diff --git a/base/observable.h b/base/observable.h index 26721895a..6fafa0b47 100644 --- a/base/observable.h +++ b/base/observable.h @@ -74,13 +74,12 @@ public: */ void operator()(const TArgs& args) { - typename vector::iterator i; - - for (i = m_Observers.begin(); i != m_Observers.end(); ) { - int result = (*i)(args); + vector::size_type i = 0; + for (i = 0; i < m_Observers.size(); i++) { + int result = m_Observers[i](args); if (result == -1) - i = m_Observers.erase(i); + m_Observers.erase(m_Observers.begin() + i); else i++; } diff --git a/dyn/configcompiler.cpp b/dyn/configcompiler.cpp index 090015226..978f86b17 100644 --- a/dyn/configcompiler.cpp +++ b/dyn/configcompiler.cpp @@ -63,6 +63,7 @@ vector ConfigCompiler::CompileStream(istream *stream) vector ConfigCompiler::CompileFile(const string& filename) { ifstream stream; + stream.exceptions(ifstream::badbit); stream.open(filename, ifstream::in); return CompileStream(&stream); } diff --git a/icinga-app/icinga1.conf b/icinga-app/icinga1.conf index 679874d3e..9dbfb2a56 100644 --- a/icinga-app/icinga1.conf +++ b/icinga-app/icinga1.conf @@ -1,39 +1,36 @@ -{ - "icinga": { - "icinga": { - "replicate": "0", - "privkey": "icinga-c1.key", - "pubkey": "icinga-c1.crt", - "cakey": "ca.crt", - "node": "10.0.10.14", - "service": "7777" - } - }, - "component": { - "configrpc": { "replicate": "0", "configSource": "1" }, - "demo": { "replicate": "0" }, - "discovery": { "replicate": "0", "broker": "1" } - }, - "host": { - "localhost": { "node": "127.0.0.1" } - }, - "endpoint": { - "icinga-c2": { - "replicate": "0", - "roles": [ "demo" ] - }, - "icinga-c3": { - "replicate": "0", - "roles": [ "demo" ] - } - }, - "role": { - "broker": { - "publications": [ "discovery::NewComponent" ] - }, - "demo": { - "publications": [ "demo::*" ], - "subscriptions": [ "demo::*" ] - } - } -} \ No newline at end of file +local object application "icinga" { + privkey = "icinga-c1.key", + pubkey = "icinga-c1.crt", + cakey = "ca.crt", + + node = "10.0.10.14", + service = 7777 +} + +local object component "configrpc" { + configSource = 1 +} + +local object component "demo" { +} + +local object component "discovery" { + broker = 1 +} + +local object endpoint "icinga-c2" { + roles = { "demo" } +} + +local object endpoint "icinga-c3" { + roles = { "demo" } +} + +local object role "broker" { + publications = { "discovery::NewComponent" } +} + +local object role "demo" { + publications = { "demo::*" }, + subscriptions = { "demo::*" } +} diff --git a/icinga.sln b/icinga.sln index f9766e2d6..1cfbaaa5f 100644 --- a/icinga.sln +++ b/icinga.sln @@ -29,7 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\ic EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfile", "components\configfile\configfile.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}" ProjectSection(ProjectDependencies) = postProject - {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} + {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677} + {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpc", "components\configrpc\configrpc.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}" diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index f4c326848..642c4df4a 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -52,6 +52,19 @@ int IcingaApplication::Main(const vector& args) string componentDirectory = GetExeDirectory() + "/../lib/icinga2"; AddComponentSearchDir(componentDirectory); + /* register handler for 'component' config objects */ + static ConfigObject::Set::Ptr componentObjects = make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component")); + function&)> NewComponentHandler = bind_weak(&IcingaApplication::NewComponentHandler, shared_from_this()); + componentObjects->OnObjectAdded += NewComponentHandler; + componentObjects->OnObjectCommitted += NewComponentHandler; + componentObjects->OnObjectRemoved += bind_weak(&IcingaApplication::DeletedComponentHandler, shared_from_this()); + componentObjects->Start(); + + /* load config file */ + ConfigObject::Ptr fileComponentConfig = make_shared("component", "configfile"); + fileComponentConfig->SetProperty("configFilename", args[1]); + fileComponentConfig->Commit(); + ConfigObject::Ptr icingaConfig = ConfigObject::GetObject("application", "icinga"); if (!icingaConfig) @@ -66,19 +79,6 @@ int IcingaApplication::Main(const vector& args) icingaConfig->GetProperty("node", &m_Node); icingaConfig->GetProperty("service", &m_Service); - /* register handler for 'component' config objects */ - static ConfigObject::Set::Ptr componentObjects = make_shared(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component")); - function&)> NewComponentHandler = bind_weak(&IcingaApplication::NewComponentHandler, shared_from_this()); - componentObjects->OnObjectAdded += NewComponentHandler; - componentObjects->OnObjectCommitted += NewComponentHandler; - componentObjects->OnObjectRemoved += bind_weak(&IcingaApplication::DeletedComponentHandler, shared_from_this()); - componentObjects->Start(); - - /* load config file */ - ConfigObject::Ptr fileComponentConfig = make_shared("component", "configfile"); - fileComponentConfig->GetProperties()->SetProperty("configFilename", args[1]); - fileComponentConfig->Commit(); - if (!GetPrivateKeyFile().empty() && !GetPublicKeyFile().empty() && !GetCAKeyFile().empty()) { /* set up SSL context */ shared_ptr cert = Utility::GetX509Certificate(GetPublicKeyFile());