Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
mzimbres committed Dec 1, 2024
1 parent f6e14c2 commit b0213d4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions include/boost/redis/detail/health_checker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ class ping_op {
BOOST_ASIO_CORO_REENTER (coro_) for (;;)
{
if (checker_->ping_interval_ == std::chrono::seconds::zero()) {
logger_.trace("ping_op: timeout disabled.");
logger_.trace("ping_op (1): timeout disabled.");
BOOST_ASIO_CORO_YIELD
asio::post(std::move(self));
self.complete({});
return;
}

if (checker_->checker_has_exited_) {
logger_.trace("ping_op: checker has exited.");
logger_.trace("ping_op (2): checker has exited.");
self.complete({});
return;
}

BOOST_ASIO_CORO_YIELD
conn_->async_exec(checker_->req_, checker_->resp_, std::move(self));
if (ec) {
logger_.trace("ping_op (exec)", ec);
logger_.trace("ping_op (3)", ec);
checker_->wait_timer_.cancel();
self.complete(ec);
return;
Expand All @@ -63,7 +63,7 @@ class ping_op {
BOOST_ASIO_CORO_YIELD
checker_->ping_timer_.async_wait(std::move(self));
if (ec) {
logger_.trace("ping_op (wait)", ec);
logger_.trace("ping_op (4)", ec);
self.complete(ec);
return;
}
Expand All @@ -85,7 +85,7 @@ class check_timeout_op {
BOOST_ASIO_CORO_REENTER (coro_) for (;;)
{
if (checker_->ping_interval_ == std::chrono::seconds::zero()) {
logger_.trace("check_timeout_op: timeout disabled.");
logger_.trace("check_timeout_op (1): timeout disabled.");
BOOST_ASIO_CORO_YIELD
asio::post(std::move(self));
self.complete({});
Expand All @@ -97,19 +97,20 @@ class check_timeout_op {
BOOST_ASIO_CORO_YIELD
checker_->wait_timer_.async_wait(std::move(self));
if (ec) {
logger_.trace("check_timeout_op (async_wait)", ec);
logger_.trace("check_timeout_op (2)", ec);
self.complete(ec);
return;
}

if (checker_->resp_.has_error()) {
logger_.trace("check_timeout_op: Response error.");
// TODO: Log the error.
logger_.trace("check_timeout_op (3): Response error.");
self.complete({});
return;
}

if (checker_->resp_.value().empty()) {
logger_.trace("check_timeout_op: pong timeout.");
logger_.trace("check_timeout_op (4): pong timeout.");
checker_->ping_timer_.cancel();
conn_->cancel(operation::run);
checker_->checker_has_exited_ = true;
Expand Down Expand Up @@ -166,14 +167,14 @@ class health_checker {
template <class Connection, class Logger, class CompletionToken>
auto async_check_timeout(Connection& conn, Logger l, CompletionToken token)
{
checker_has_exited_ = false;
return asio::async_compose
< CompletionToken
, void(system::error_code)
>(check_timeout_op<health_checker, Connection, Logger>{this, &conn, l}, token, conn, wait_timer_);
}

private:

template <class, class, class> friend class ping_op;
template <class, class, class> friend class check_timeout_op;

Expand Down

0 comments on commit b0213d4

Please sign in to comment.