Skip to content

Commit

Permalink
chore: call breaker_cb_ on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
romange committed Jun 5, 2024
1 parent 90b5ec4 commit 955a552
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
22 changes: 2 additions & 20 deletions src/facade/dragonfly_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -600,21 +597,6 @@ void Connection::OnPostMigrateThread() {
}
}

auto Connection::RegisterShutdownHook(ShutdownCb cb) -> ShutdownHandle {
if (!shutdown_cb_) {
shutdown_cb_ = make_unique<Shutdown>();
}
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");

Expand Down
6 changes: 0 additions & 6 deletions src/facade/dragonfly_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -428,7 +423,6 @@ class Connection : public util::Connection {
unsigned parser_error_ = 0;

BreakerCb breaker_cb_;
std::unique_ptr<Shutdown> shutdown_cb_;

// Used by redis parser to avoid allocations
RespVec tmp_parse_args_;
Expand Down

0 comments on commit 955a552

Please sign in to comment.