From c3c7189e612cea41e8e3f6248550e46f02895b98 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 13 May 2025 12:26:48 -0400 Subject: [PATCH] msg: add interface to shutdown Connection Unfortunately this doesn't work as-is because I couldn't find primitives to flush the out_queue. It's left as a to-do for now. Signed-off-by: Patrick Donnelly (cherry picked from commit 05e3b36fa2d877b2d7451ccda9ce6da73690ba50) --- src/mon/Monitor.cc | 3 +++ src/msg/Connection.h | 6 ++++++ src/msg/async/AsyncConnection.cc | 6 ++++++ src/msg/async/AsyncConnection.h | 1 + 4 files changed, 16 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 2a940044012..25cc1d4711f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4150,6 +4150,9 @@ struct AnonConnection : public Connection { void mark_down() override { // silently ignore } + void shutdown() override { + // silengtly ignore + } void mark_disposable() override { // silengtly ignore } diff --git a/src/msg/Connection.h b/src/msg/Connection.h index 801d3fa200f..14d732973d3 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -157,6 +157,12 @@ public: */ virtual void mark_disposable() = 0; + /* + * Politely shutdown the connection. Finish sending any messages. This + * queues a connection reset event. + */ + virtual void shutdown() = 0; + // WARNING / FIXME: this is not populated for loopback connections AuthCapsInfo& get_peer_caps_info() { return peer_caps_info; diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index ab3d454748e..c686c5c470f 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -753,6 +753,12 @@ void AsyncConnection::stop(bool queue_reset) { if (need_queue_reset) dispatch_queue->queue_reset(this); } +void AsyncConnection::shutdown() +{ + /* FIXME: stop() discards out queue so this doesn't actually flush sent messages */ + return stop(true); +} + void AsyncConnection::cleanup() { shutdown_socket(); delete read_handler; diff --git a/src/msg/async/AsyncConnection.h b/src/msg/async/AsyncConnection.h index a4f18e2c4fb..7eaddc183ad 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -235,6 +235,7 @@ private: void process(); void wakeup_from(uint64_t id); void tick(uint64_t id); + void shutdown() override; void stop(bool queue_reset); void cleanup(); PerfCounters *get_perf_counter() { -- 2.39.5