Check if RedisConnection exists before checking connection

This commit is contained in:
Jean Flach 2018-11-26 13:34:05 +01:00 committed by Michael Friedrich
parent a056e14834
commit 5f64d809d7
2 changed files with 5 additions and 5 deletions

View File

@ -153,7 +153,7 @@ static ConfigObject::Ptr GetObjectByName(const String& name)
// Used to update a single object, used for runtime updates // Used to update a single object, used for runtime updates
void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate) void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate)
{ {
if (!m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
String typeName = GetLowerCaseTypeNameDB(object); String typeName = GetLowerCaseTypeNameDB(object);

View File

@ -111,7 +111,7 @@ void RedisWriter::TryToReconnect()
else else
m_Rcon->Start(); m_Rcon->Start();
if (!m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
UpdateSubscriptions(); 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 * 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. * 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; return;
long long cursor = 0; long long cursor = 0;
@ -220,7 +220,7 @@ void RedisWriter::PublishStats()
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
if (!m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
Dictionary::Ptr status = GetStats(); Dictionary::Ptr status = GetStats();
@ -303,7 +303,7 @@ void RedisWriter::SendEvent(const Dictionary::Ptr& event)
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
if (!m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
String type = event->Get("type"); String type = event->Get("type");