mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
IcingaDB::SendCustomVarsChanged(): don't delete custom vars of not synced types
not to surprise (and crash) the Icinga DB daemon with unknown types.
This commit is contained in:
parent
a6d2970604
commit
ac57ed6cb4
@ -44,6 +44,8 @@ using namespace icinga;
|
|||||||
|
|
||||||
using Prio = RedisConnection::QueryPriority;
|
using Prio = RedisConnection::QueryPriority;
|
||||||
|
|
||||||
|
std::unordered_set<Type*> IcingaDB::m_IndexedTypes;
|
||||||
|
|
||||||
INITIALIZE_ONCE(&IcingaDB::ConfigStaticInitialize);
|
INITIALIZE_ONCE(&IcingaDB::ConfigStaticInitialize);
|
||||||
|
|
||||||
std::vector<Type::Ptr> IcingaDB::GetTypes()
|
std::vector<Type::Ptr> IcingaDB::GetTypes()
|
||||||
@ -74,6 +76,10 @@ std::vector<Type::Ptr> IcingaDB::GetTypes()
|
|||||||
|
|
||||||
void IcingaDB::ConfigStaticInitialize()
|
void IcingaDB::ConfigStaticInitialize()
|
||||||
{
|
{
|
||||||
|
for (auto& type : GetTypes()) {
|
||||||
|
m_IndexedTypes.emplace(type.get());
|
||||||
|
}
|
||||||
|
|
||||||
/* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */
|
/* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */
|
||||||
Checkable::OnStateChange.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type, const MessageOrigin::Ptr&) {
|
Checkable::OnStateChange.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type, const MessageOrigin::Ptr&) {
|
||||||
IcingaDB::StateChangeHandler(checkable, cr, type);
|
IcingaDB::StateChangeHandler(checkable, cr, type);
|
||||||
@ -2511,6 +2517,10 @@ void IcingaDB::SendCommandArgumentsChanged(const ConfigObject::Ptr& command, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IcingaDB::SendCustomVarsChanged(const ConfigObject::Ptr& object, const Dictionary::Ptr& oldValues, const Dictionary::Ptr& newValues) {
|
void IcingaDB::SendCustomVarsChanged(const ConfigObject::Ptr& object, const Dictionary::Ptr& oldValues, const Dictionary::Ptr& newValues) {
|
||||||
|
if (m_IndexedTypes.find(object->GetReflectionType().get()) == m_IndexedTypes.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_Rcon || !m_Rcon->IsConnected() || oldValues == newValues) {
|
if (!m_Rcon || !m_Rcon->IsConnected() || oldValues == newValues) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
@ -232,6 +233,8 @@ private:
|
|||||||
// initialization, the value is read-only and can be accessed without further synchronization.
|
// initialization, the value is read-only and can be accessed without further synchronization.
|
||||||
static String m_EnvironmentId;
|
static String m_EnvironmentId;
|
||||||
static std::mutex m_EnvironmentIdInitMutex;
|
static std::mutex m_EnvironmentIdInitMutex;
|
||||||
|
|
||||||
|
static std::unordered_set<Type*> m_IndexedTypes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user