From: Yingxin Cheng Date: Wed, 16 Nov 2022 05:16:07 +0000 (+0800) Subject: crimson/net: split gate for handshake and IO X-Git-Tag: v18.1.0~375^2~29 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fa0ef9e627ef56fcf3219a323dd97297bafb4e8c;p=ceph.git crimson/net: split gate for handshake and IO Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index 5260f05bae73a..260634a282846 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -90,6 +90,11 @@ class Protocol { // TODO: encapsulate a SessionedSender class protected: + seastar::future<> close_out() { + assert(!gate.is_closed()); + return gate.close(); + } + /** * out_state_t * @@ -165,8 +170,6 @@ class Protocol { return ++out_seq; } - crimson::common::Gated gate; - ChainedDispatchers& dispatchers; SocketConnection &conn; @@ -184,6 +187,8 @@ class Protocol { void notify_out_dispatch(); + crimson::common::Gated gate; + /* * out states for writing */ diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 794698b96e18d..3b16818cc62ac 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -2159,6 +2159,7 @@ void ProtocolV2::do_close( } assert(!gate.is_closed()); auto gate_closed = gate.close(); + auto out_closed = close_out(); if (dispatch_reset) { dispatchers.ms_handle_reset( @@ -2168,7 +2169,9 @@ void ProtocolV2::do_close( // asynchronous operations assert(!closed_clean_fut.valid()); - closed_clean_fut = std::move(gate_closed).then([this] { + closed_clean_fut = seastar::when_all( + std::move(gate_closed), std::move(out_closed) + ).discard_result().then([this] { if (conn.socket) { return conn.socket->close(); } else { diff --git a/src/crimson/net/ProtocolV2.h b/src/crimson/net/ProtocolV2.h index 40c32136b705d..47584e702a8f6 100644 --- a/src/crimson/net/ProtocolV2.h +++ b/src/crimson/net/ProtocolV2.h @@ -62,6 +62,8 @@ class ProtocolV2 final : public Protocol { AuthConnectionMetaRef auth_meta; + crimson::common::Gated gate; + bool closed = false; // become valid only after closed == true