From: Patrick Donnelly Date: Tue, 13 May 2025 16:26:48 +0000 (-0400) Subject: msg: add interface to shutdown Connection X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=d68685517c8194d021db17c09924b54dc0b2f225;p=ceph-ci.git 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 --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index d45b2d3c4ad..f126f24c32e 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4188,6 +4188,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 2f247535dea..3eea7ba80e4 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -759,6 +759,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 03a674871fb..4b4acd695a6 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -237,6 +237,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() {