From e87816c6850cbb369262db525421305aa509a7d9 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Wed, 5 Jun 2024 08:54:05 +0300 Subject: [PATCH] chore: call breaker_cb_ on shutdown Signed-off-by: Roman Gershman --- .../reusable-container-workflow.yaml | 2 +- src/facade/dragonfly_connection.cc | 22 ++----------------- src/facade/dragonfly_connection.h | 6 ----- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/.github/workflows/reusable-container-workflow.yaml b/.github/workflows/reusable-container-workflow.yaml index 35981ce1c4ed..8998a5dc32e3 100644 --- a/.github/workflows/reusable-container-workflow.yaml +++ b/.github/workflows/reusable-container-workflow.yaml @@ -150,7 +150,7 @@ jobs: - if: ${{ hashFiles(format('{0}-{1}', matrix.dockerfile, inputs.build_type)) }} name: Build release image for arm64 - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: context: . platforms: linux/arm64 diff --git a/src/facade/dragonfly_connection.cc b/src/facade/dragonfly_connection.cc index c5d5370a27fc..4ddbf46db913 100644 --- a/src/facade/dragonfly_connection.cc +++ b/src/facade/dragonfly_connection.cc @@ -552,11 +552,8 @@ Connection::~Connection() { void Connection::OnShutdown() { VLOG(1) << "Connection::OnShutdown"; - if (shutdown_cb_) { - for (const auto& k_v : shutdown_cb_->map) { - k_v.second(); - } - } + if (breaker_cb_) + breaker_cb_(POLLHUP); } void Connection::OnPreMigrateThread() { @@ -600,21 +597,6 @@ void Connection::OnPostMigrateThread() { } } -auto Connection::RegisterShutdownHook(ShutdownCb cb) -> ShutdownHandle { - if (!shutdown_cb_) { - shutdown_cb_ = make_unique(); - } - return shutdown_cb_->Add(std::move(cb)); -} - -void Connection::UnregisterShutdownHook(ShutdownHandle id) { - if (shutdown_cb_) { - shutdown_cb_->Remove(id); - if (shutdown_cb_->map.empty()) - shutdown_cb_.reset(); - } -} - void Connection::HandleRequests() { ThisFiber::SetName("DflyConnection"); diff --git a/src/facade/dragonfly_connection.h b/src/facade/dragonfly_connection.h index 4521846f05d5..6c9fd54f8fbd 100644 --- a/src/facade/dragonfly_connection.h +++ b/src/facade/dragonfly_connection.h @@ -238,11 +238,6 @@ class Connection : public util::Connection { // reached. Blocks until free space is available. Controlled with `pipeline_queue_limit` flag. void EnsureAsyncMemoryBudget(); - // Register hook that is executed on connection shutdown. - ShutdownHandle RegisterShutdownHook(ShutdownCb cb); - - void UnregisterShutdownHook(ShutdownHandle id); - // Register hook that is executen when the connection breaks. void RegisterBreakHook(BreakerCb breaker_cb); @@ -428,7 +423,6 @@ class Connection : public util::Connection { unsigned parser_error_ = 0; BreakerCb breaker_cb_; - std::unique_ptr shutdown_cb_; // Used by redis parser to avoid allocations RespVec tmp_parse_args_;