From 5b8a834713b09455ff13e838b9059eb2c68a3889 Mon Sep 17 00:00:00 2001 From: pnorbert Date: Tue, 23 Jul 2024 18:03:33 -0400 Subject: [PATCH] Don't print kvcache connection closed message when it was not opened. (#4251) * Don't print kvcache connection closed message when it was not opened. * find hiredis when working with static build/test/install --- cmake/adios2-config-common.cmake.in | 5 +++++ source/adios2/toolkit/kvcache/KVCacheCommon.cpp | 3 ++- source/adios2/toolkit/kvcache/KVCacheCommon.h | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cmake/adios2-config-common.cmake.in b/cmake/adios2-config-common.cmake.in index dc936a2c46..f13fb2c05b 100644 --- a/cmake/adios2-config-common.cmake.in +++ b/cmake/adios2-config-common.cmake.in @@ -158,6 +158,11 @@ if(NOT @BUILD_SHARED_LIBS@) find_dependency(SQLite3) endif() + set(ADIOS2_HAVE_KVCACHE @ADIOS2_HAVE_KVCACHE@) + if(ADIOS2_HAVE_KVCACHE) + find_dependency(hiredis) + endif() + adios2_add_thirdparty_target(pugixml) set(ADIOS2_USE_EXTERNAL_PUGIXML @ADIOS2_USE_EXTERNAL_PUGIXML@) diff --git a/source/adios2/toolkit/kvcache/KVCacheCommon.cpp b/source/adios2/toolkit/kvcache/KVCacheCommon.cpp index 5d24dee1e7..a61058039e 100644 --- a/source/adios2/toolkit/kvcache/KVCacheCommon.cpp +++ b/source/adios2/toolkit/kvcache/KVCacheCommon.cpp @@ -13,12 +13,13 @@ namespace kvcache void KVCacheCommon::OpenConnection(std::string host, int port) { m_redisContext = redisConnect(host.c_str(), port); - if (m_redisContext == NULL || m_redisContext->err) + if (m_redisContext == nullptr || m_redisContext->err) { std::cout << "Error to connect to kvcache server: " << m_redisContext->errstr << std::endl; if (m_redisContext) { redisFree(m_redisContext); + m_redisContext = nullptr; } } else diff --git a/source/adios2/toolkit/kvcache/KVCacheCommon.h b/source/adios2/toolkit/kvcache/KVCacheCommon.h index f17f25117a..d01689e546 100644 --- a/source/adios2/toolkit/kvcache/KVCacheCommon.h +++ b/source/adios2/toolkit/kvcache/KVCacheCommon.h @@ -23,8 +23,8 @@ class KVCacheCommon { #ifdef ADIOS2_HAVE_KVCACHE private: - redisContext *m_redisContext; - redisReply *m_redisReply; + redisContext *m_redisContext = nullptr; + redisReply *m_redisReply = nullptr; public: ~KVCacheCommon() { CloseConnection(); }