From 732d5c472d3a06dd55a7c5a47d112a619c4152b4 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 9 Feb 2022 15:20:05 +0100 Subject: [PATCH] RedisConnection#ReadLoop(): don't crash (silently) if a promise to be set is already set --- lib/icingadb/redisconnection.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/icingadb/redisconnection.cpp b/lib/icingadb/redisconnection.cpp index 7537f0271..9bc62c0d2 100644 --- a/lib/icingadb/redisconnection.cpp +++ b/lib/icingadb/redisconnection.cpp @@ -413,12 +413,16 @@ void RedisConnection::ReadLoop(asio::yield_context& yc) throw; } catch (...) { promise.set_exception(std::current_exception()); - - continue; + break; } } - promise.set_value(std::move(replies)); + try { + promise.set_value(std::move(replies)); + } catch (const std::future_error&) { + // Complaint about the above op is not allowed + // due to promise.set_exception() was already called + } } } }