From: Patrick Donnelly Date: Tue, 13 May 2025 16:26:48 +0000 (-0400) Subject: msg: add interface to shutdown Connection X-Git-Tag: testing/wip-pdonnell-testing-20260126.152838~71 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a789dc0bd2d3afc1fe467f7930cc144537cf77b5;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 9fc59b50e0f..4409cc9b0b7 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -4209,6 +4209,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 1e1dfd1aa3c..ce167343711 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -158,6 +158,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 17836b14ad2..52d1330f24e 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -760,6 +760,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 45293133023..ac11fd1ae9d 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -238,6 +238,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() {