From f1136e32d33ae8624f56c7ccf0ad0e4222113d12 Mon Sep 17 00:00:00 2001 From: Marcelo Zimbres Date: Sun, 18 Aug 2024 11:11:05 +0200 Subject: [PATCH] Improves reconnection responsiveness. As the user points out in https://github.com/boostorg/redis/issues/205 wait_for_all might be the cause of delay in the reconnection. I could not observe any improvement in my local setup but wait_for_one_error look the correct token and all tests pass so I am willing to change it. --- README.md | 6 ++++++ include/boost/redis/detail/runner.hpp | 2 +- test/test_conn_exec.cpp | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8634425d..7f500c79 100644 --- a/README.md +++ b/README.md @@ -676,6 +676,12 @@ https://lists.boost.org/Archives/boost/2023/01/253944.php. ## Changelog +### Boost 1.87 + +* ([Issue 205](https://github.com/boostorg/redis/issues/205)) + Improves reaction time to disconnection by using `wait_for_one_error` + instead of `wait_for_all`. + ### Boost 1.85 * ([Issue 170](https://github.com/boostorg/redis/issues/170)) diff --git a/include/boost/redis/detail/runner.hpp b/include/boost/redis/detail/runner.hpp index f257019b..de185e71 100644 --- a/include/boost/redis/detail/runner.hpp +++ b/include/boost/redis/detail/runner.hpp @@ -93,7 +93,7 @@ class runner_op { [this](auto token) { return runner_->health_checker_.async_check_health(*conn_, logger_, token); }, [this](auto token) { return runner_->async_hello(*conn_, logger_, token); } ).async_wait( - asio::experimental::wait_for_all(), + asio::experimental::wait_for_one_error(), std::move(self)); logger_.on_runner(ec0, ec1, ec2); diff --git a/test/test_conn_exec.cpp b/test/test_conn_exec.cpp index c3f04134..e55c325a 100644 --- a/test/test_conn_exec.cpp +++ b/test/test_conn_exec.cpp @@ -152,6 +152,9 @@ BOOST_AUTO_TEST_CASE(correct_database) auto const pos = value.find("db="); auto const index_str = value.substr(pos + 3, 1); auto const index = std::stoi(index_str); + + // This check might fail if more than one client is connected to + // redis when the CLIENT LIST command is run. BOOST_CHECK_EQUAL(cfg.database_index.value(), index); }