From c1c50e3e24c570ce47670cb5d4e3e5fe601393ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anarthal=20=28Rub=C3=A9n=20P=C3=A9rez=29?= <34971811+anarthal@users.noreply.github.com> Date: Mon, 19 May 2025 16:46:56 +0200 Subject: [PATCH] Reconnection no longer causes the writer to perform busy waiting (#253) Reconnection now uses a separate timer to wait close #252 --- include/boost/redis/connection.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/redis/connection.hpp b/include/boost/redis/connection.hpp index ea364c91..16f8352e 100644 --- a/include/boost/redis/connection.hpp +++ b/include/boost/redis/connection.hpp @@ -442,12 +442,10 @@ public: return; } - // It is safe to use the writer timer here because we are not - // connected. - conn_->writer_timer_.expires_after(conn_->cfg_.reconnect_wait_interval); + conn_->reconnect_timer_.expires_after(conn_->cfg_.reconnect_wait_interval); BOOST_ASIO_CORO_YIELD - conn_->writer_timer_.async_wait(asio::prepend(std::move(self), order_t{})); + conn_->reconnect_timer_.async_wait(asio::prepend(std::move(self), order_t{})); if (ec0) { self.complete(ec0); return; @@ -507,6 +505,7 @@ public: : ctx_{std::move(ctx)} , stream_{std::make_unique(ex, ctx_)} , writer_timer_{ex} + , reconnect_timer_{ex} , receive_channel_{ex, 256} , resv_{ex} , health_checker_{ex} @@ -826,6 +825,7 @@ private: // also more suitable than a channel and the notify operation does // not suspend. timer_type writer_timer_; + timer_type reconnect_timer_; // to wait the reconnection period receive_channel_type receive_channel_; resolver_type resv_; detail::connector ctor_;