Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions common/redispipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,38 @@ class RedisPipeline {
lastHeartBeat = std::chrono::steady_clock::now();
}

~RedisPipeline() {
if (m_ownerTid == gettid())
~RedisPipeline() noexcept {
try
{
// call flush from different thread will trigger race condition issue.
flush();
std::string dbName = getDbName();

if (m_ownerTid == gettid())
{
// call flush from different thread will trigger race condition issue.
try
{
flush();
}
catch (const std::exception& e)
{
SWSS_LOG_ERROR("Exception during RedisPipeline flush in destructor: %s, Database: %s", e.what(), dbName.c_str());
}
}
else
{
SWSS_LOG_NOTICE("RedisPipeline dtor is called from another thread, possibly due to exit(), Database: %s", dbName.c_str());
}

delete m_db;
}
else
catch (const std::exception& e)
{
SWSS_LOG_NOTICE("RedisPipeline dtor is called from another thread, possibly due to exit(), Database: %s", getDbName().c_str());
fprintf(stderr, "Exception during RedisPipeline destructor: %s\n", e.what());
}
catch (...)
{
fprintf(stderr, "Unknown exception during RedisPipeline destructor\n");
}

delete m_db;
}

redisReply *push(const RedisCommand& command, int expectedType)
Expand Down
Loading