Skip to content

Commit

Permalink
Don't print kvcache connection closed message when it was not opened. (
Browse files Browse the repository at this point in the history
…#4251)

* Don't print kvcache connection closed message when it was not opened.

* find hiredis when working with static build/test/install
  • Loading branch information
pnorbert authored Jul 23, 2024
1 parent b8802f6 commit 5b8a834
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cmake/adios2-config-common.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@)
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/toolkit/kvcache/KVCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/adios2/toolkit/kvcache/KVCacheCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down

0 comments on commit 5b8a834

Please sign in to comment.