From 5f64d809d7b69d3f1bca9474d0544a13bdeb9a7f Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Mon, 26 Nov 2018 13:34:05 +0100 Subject: [PATCH] Check if RedisConnection exists before checking connection --- lib/redis/rediswriter-objects.cpp | 2 +- lib/redis/rediswriter.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/redis/rediswriter-objects.cpp b/lib/redis/rediswriter-objects.cpp index 8b0e972d4..3673973ff 100644 --- a/lib/redis/rediswriter-objects.cpp +++ b/lib/redis/rediswriter-objects.cpp @@ -153,7 +153,7 @@ static ConfigObject::Ptr GetObjectByName(const String& name) // Used to update a single object, used for runtime updates void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate) { - if (!m_Rcon->IsConnected()) + if (!m_Rcon || !m_Rcon->IsConnected()) return; String typeName = GetLowerCaseTypeNameDB(object); diff --git a/lib/redis/rediswriter.cpp b/lib/redis/rediswriter.cpp index b9843da45..41fe0d048 100644 --- a/lib/redis/rediswriter.cpp +++ b/lib/redis/rediswriter.cpp @@ -111,7 +111,7 @@ void RedisWriter::TryToReconnect() else m_Rcon->Start(); - if (!m_Rcon->IsConnected()) + if (!m_Rcon || !m_Rcon->IsConnected()) return; UpdateSubscriptions(); @@ -145,7 +145,7 @@ void RedisWriter::UpdateSubscriptions() * 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()) + if (!m_Rcon || !m_Rcon->IsConnected()) return; long long cursor = 0; @@ -220,7 +220,7 @@ void RedisWriter::PublishStats() { AssertOnWorkQueue(); - if (!m_Rcon->IsConnected()) + if (!m_Rcon || !m_Rcon->IsConnected()) return; Dictionary::Ptr status = GetStats(); @@ -303,7 +303,7 @@ void RedisWriter::SendEvent(const Dictionary::Ptr& event) { AssertOnWorkQueue(); - if (!m_Rcon->IsConnected()) + if (!m_Rcon || !m_Rcon->IsConnected()) return; String type = event->Get("type");