mirror of https://github.com/Icinga/icinga2.git
Fix segfault with zones without endpoints on config compile.
Fixes #6425
This commit is contained in:
parent
addad4ae9c
commit
78e4b28006
|
@ -40,6 +40,9 @@ void Endpoint::OnConfigLoaded(void)
|
|||
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
|
||||
const std::set<Endpoint::Ptr> members = zone->GetEndpoints();
|
||||
|
||||
if (members.empty())
|
||||
continue;
|
||||
|
||||
if (members.find(GetSelf()) != members.end()) {
|
||||
if (m_Zone)
|
||||
BOOST_THROW_EXCEPTION(std::runtime_error("Endpoint '" + GetName() + "' is in more than one zone."));
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "remote/zone.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
using namespace icinga;
|
||||
|
@ -33,8 +34,20 @@ std::set<Endpoint::Ptr> Zone::GetEndpoints(void) const
|
|||
{
|
||||
std::set<Endpoint::Ptr> result;
|
||||
|
||||
BOOST_FOREACH(const String& endpoint, GetEndpointsRaw())
|
||||
result.insert(Endpoint::GetByName(endpoint));
|
||||
Array::Ptr endpoints = GetEndpointsRaw();
|
||||
|
||||
if (endpoints) {
|
||||
ObjectLock olock(endpoints);
|
||||
|
||||
BOOST_FOREACH(const String& name, endpoints) {
|
||||
Endpoint::Ptr endpoint = Endpoint::GetByName(name);
|
||||
|
||||
if (!endpoint)
|
||||
continue;
|
||||
|
||||
result.insert(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue