Skip to content

Commit ce4e5cb

Browse files
committed
Improves reconnection responsiveness.
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.
1 parent c370e93 commit ce4e5cb

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,14 @@ https://lists.boost.org/Archives/boost/2023/01/253944.php.
676676

677677
## Changelog
678678

679+
### Boost 1.87
680+
681+
* ([Issue 205](https://github.com/boostorg/redis/issues/205))
682+
Improves reaction time to disconnection by using `wait_for_one_error`
683+
instead of `wait_for_all`. The function `connection::async_run` was
684+
also changed to return EOF to the user when that error is received
685+
from the server. That is a breaking change.
686+
679687
### Boost 1.85
680688

681689
* ([Issue 170](https://github.com/boostorg/redis/issues/170))

include/boost/redis/detail/connection_base.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ struct reader_op {
317317
if (ec == asio::error::eof) {
318318
logger_.trace("reader-op: EOF received. Exiting ...");
319319
conn_->cancel(operation::run);
320-
return self.complete({}); // EOFINAE: EOF is not an error.
320+
return self.complete(ec);
321321
}
322322

323323
// The connection is not viable after an error.

include/boost/redis/detail/runner.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class runner_op {
9393
[this](auto token) { return runner_->health_checker_.async_check_health(*conn_, logger_, token); },
9494
[this](auto token) { return runner_->async_hello(*conn_, logger_, token); }
9595
).async_wait(
96-
asio::experimental::wait_for_all(),
96+
asio::experimental::wait_for_one_error(),
9797
std::move(self));
9898

9999
logger_.on_runner(ec0, ec1, ec2);

test/test_conn_exec.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ BOOST_AUTO_TEST_CASE(correct_database)
152152
auto const pos = value.find("db=");
153153
auto const index_str = value.substr(pos + 3, 1);
154154
auto const index = std::stoi(index_str);
155+
156+
// This check might fail if more than one client is connected to
157+
// redis when the CLIENT LIST command is run.
155158
BOOST_CHECK_EQUAL(cfg.database_index.value(), index);
156159
}
157160

0 commit comments

Comments
 (0)