From 1f473d649a428fb3fcfc707f01db1f4088bd7064 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Fri, 2 Dec 2022 16:56:13 +0800 Subject: [PATCH] crimson/net: unshare conn for ProtocolV2 and Protocol Signed-off-by: Yingxin Cheng --- src/crimson/net/Protocol.h | 4 ++-- src/crimson/net/ProtocolV2.cc | 6 +++--- src/crimson/net/ProtocolV2.h | 5 +++-- src/crimson/net/SocketConnection.cc | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index f1e7d2bb0da..215c951331e 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -129,8 +129,6 @@ class Protocol { ChainedDispatchers& dispatchers; - SocketConnection &conn; - private: bool is_out_queued() const { return (!out_pending_msgs.empty() || @@ -156,6 +154,8 @@ class Protocol { void do_in_dispatch(); + SocketConnection &conn; + crimson::common::Gated gate; FrameAssemblerV2Ref frame_assembler; diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 8c3c2e54806..a99dd0d4bf9 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -156,10 +156,10 @@ seastar::future<> ProtocolV2::Timer::backoff(double seconds) } ProtocolV2::ProtocolV2(ChainedDispatchers& dispatchers, - SocketConnection& conn, - SocketMessenger& messenger) + SocketConnection& conn) : Protocol(dispatchers, conn), - messenger{messenger}, + conn{conn}, + messenger{conn.messenger}, frame_assembler{FrameAssemblerV2::create(conn)}, auth_meta{seastar::make_lw_shared()}, protocol_timer{conn} diff --git a/src/crimson/net/ProtocolV2.h b/src/crimson/net/ProtocolV2.h index 0b915540adc..d60b1be83b4 100644 --- a/src/crimson/net/ProtocolV2.h +++ b/src/crimson/net/ProtocolV2.h @@ -14,8 +14,7 @@ class ProtocolV2 final : public Protocol { public: ProtocolV2(ChainedDispatchers& dispatchers, - SocketConnection& conn, - SocketMessenger& messenger); + SocketConnection& conn); ~ProtocolV2() override; // public to SocketConnection, but private to the others @@ -58,6 +57,8 @@ class ProtocolV2 final : public Protocol { } private: + SocketConnection &conn; + SocketMessenger &messenger; bool has_socket = false; diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 9f989e21c2f..e4a2d7d789b 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -29,7 +29,7 @@ SocketConnection::SocketConnection(SocketMessenger& messenger, ChainedDispatchers& dispatchers) : core(messenger.shard_id()), messenger(messenger), - protocol(std::make_unique(dispatchers, *this, messenger)) + protocol(std::make_unique(dispatchers, *this)) { #ifdef UNIT_TESTS_BUILT if (messenger.interceptor) { -- 2.39.5