Skip to content

Commit

Permalink
Improves reconnection responsiveness.
Browse files Browse the repository at this point in the history
As the user points out in

   #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.
  • Loading branch information
mzimbres committed Sep 8, 2024
1 parent e8dd4d6 commit 4cfe146
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion include/boost/redis/detail/connection_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ struct reader_op {
if (ec == asio::error::eof) {
logger_.trace("reader-op: EOF received. Exiting ...");
conn_->cancel(operation::run);
return self.complete({}); // EOFINAE: EOF is not an error.
return self.complete(ec);
}

// The connection is not viable after an error.
Expand Down
2 changes: 1 addition & 1 deletion include/boost/redis/detail/runner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions test/test_conn_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 4cfe146

Please sign in to comment.