From 1d21626b302a82f6a6d3dc89c9ccd93fbdea1517 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Fri, 26 Oct 2018 15:01:05 +0200 Subject: [PATCH] Code style --- lib/redis/redisconnection.cpp | 2 +- lib/redis/rediswriter-objects.cpp | 12 ++++++------ lib/redis/rediswriter.cpp | 11 +++++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/redis/redisconnection.cpp b/lib/redis/redisconnection.cpp index 4391a68f7..9f889ab2e 100644 --- a/lib/redis/redisconnection.cpp +++ b/lib/redis/redisconnection.cpp @@ -75,7 +75,7 @@ void RedisConnection::HandleRW() void RedisConnection::RedisInitialCallback(redisAsyncContext *c, void *r, void *p) { - auto *state = (ConnectionState *) p; + auto state = (ConnectionState *) p; if (state->state != Starting && !r) { Log(LogCritical, "RedisConnection") << "No answer from Redis during initial connection, is the Redis server running?"; diff --git a/lib/redis/rediswriter-objects.cpp b/lib/redis/rediswriter-objects.cpp index 07c772642..a7f68a51e 100644 --- a/lib/redis/rediswriter-objects.cpp +++ b/lib/redis/rediswriter-objects.cpp @@ -81,9 +81,9 @@ void RedisWriter::UpdateAllConfigObjects() upq.ParallelFor(types, [this](const TypePair& type) { size_t bulkCounter = 0; - std::vector attributes = std::vector({"HMSET", m_PrefixConfigObject + type.second}); - std::vector customVars = std::vector({"HMSET", m_PrefixConfigCustomVar + type.second}); - std::vector checksums = std::vector({"HMSET", m_PrefixConfigCheckSum + type.second}); + auto attributes = std::vector({"HMSET", m_PrefixConfigObject + type.second}); + auto customVars = std::vector({"HMSET", m_PrefixConfigCustomVar + type.second}); + auto checksums = std::vector({"HMSET", m_PrefixConfigCheckSum + type.second}); for (const ConfigObject::Ptr& object : type.first->GetObjects()) { CreateConfigUpdate(object, attributes, customVars, checksums, false); @@ -138,9 +138,9 @@ static ConfigObject::Ptr GetObjectByName(const String& name) void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate) { String typeName = object->GetReflectionType()->GetName().ToLower(); - std::vector attributes = std::vector({"HMSET", m_PrefixConfigObject + typeName}); - std::vector customVars = std::vector({"HMSET", m_PrefixConfigCustomVar + typeName}); - std::vector checksums = std::vector({"HMSET", m_PrefixConfigCheckSum + typeName}); + auto attributes = std::vector({"HMSET", m_PrefixConfigObject + typeName}); + auto customVars = std::vector({"HMSET", m_PrefixConfigCustomVar + typeName}); + auto checksums = std::vector({"HMSET", m_PrefixConfigCheckSum + typeName}); CreateConfigUpdate(object, attributes, customVars, checksums, runtimeUpdate); diff --git a/lib/redis/rediswriter.cpp b/lib/redis/rediswriter.cpp index 5760d91d7..3ca657f90 100644 --- a/lib/redis/rediswriter.cpp +++ b/lib/redis/rediswriter.cpp @@ -138,11 +138,14 @@ void RedisWriter::UpdateSubscriptions() Log(LogInformation, "RedisWriter", "Updating Redis subscriptions"); - if (!m_Rcon->IsConnected()) { - Log(LogCritical, "DEBUG, Redis") - << "NO CONNECT CHIEF"; + /* TODO: + * Silently return in this case. Usually the RedisConnection checks for connectivity and logs in failure case. + * But since we expect and answer here and break Icinga in case of receiving no answer/an unexpected one we opt for + * better safe than sorry here. Future implementation needs to include an improved error handling and answer verification. + */ + if (!m_Rcon->IsConnected()) return; - } + long long cursor = 0; String keyPrefix = "icinga:subscription:";