From 84343ca9f04c6cbb169e64fe9891520ca14d360c Mon Sep 17 00:00:00 2001 From: penfree Date: Tue, 19 Dec 2023 23:45:19 +0800 Subject: [PATCH] Fix: keepalive exit without any message due to clock drift (#258) Fix: #257 Co-authored-by: qiupengfei --- src/KeepAlive.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/KeepAlive.cpp b/src/KeepAlive.cpp index 2735ac0..cb5b9bc 100644 --- a/src/KeepAlive.cpp +++ b/src/KeepAlive.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "etcd/KeepAlive.hpp" @@ -177,7 +178,11 @@ void etcd::KeepAlive::refresh() { std::unique_lock lock(mutex_for_refresh_); if (cv_for_refresh_.wait_for(lock, std::chrono::seconds(keepalive_ttl)) == std::cv_status::no_timeout) { - return; + if (!continue_next.load()) { + return; + } + std::cerr << "Warn: awaked from condition_variable" + + " but continue_next is not set, maybe due to clock drift." << std::endl; } }