From: Yingxin Cheng Date: Thu, 1 Dec 2022 01:55:34 +0000 (+0800) Subject: crimson/net: move dispatch ms_handle_connect() before READY X-Git-Tag: v18.1.0~375^2~19 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7e84140f0d3a34b880231a7a74d26536a523ca9b;p=ceph.git crimson/net: move dispatch ms_handle_connect() before READY It would be too late to notify connected after the status becomes READY and open. Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 74719ec3babf5..0d5963edff652 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -867,7 +867,14 @@ void ProtocolV2::execute_connecting() conn, global_seq, peer_global_seq, connect_seq, client_cookie, server_cookie, io_stat_printer{*this}); - execute_ready(true); + dispatchers.ms_handle_connect( + seastar::static_pointer_cast(conn.shared_from_this())); + if (unlikely(state != state_t::CONNECTING)) { + logger().debug("{} triggered {} after ms_handle_connect(), abort", + conn, get_state_name(state)); + abort_protocol(); + } + execute_ready(); break; } case next_step_t::wait: { @@ -1594,7 +1601,7 @@ void ProtocolV2::execute_establishing(SocketConnectionRef existing_conn) { conn, global_seq, peer_global_seq, connect_seq, client_cookie, server_cookie, io_stat_printer{*this}); - execute_ready(false); + execute_ready(); }).handle_exception([this](std::exception_ptr eptr) { fault(state_t::ESTABLISHING, "execute_establishing", eptr); }); @@ -1750,7 +1757,7 @@ void ProtocolV2::trigger_replacing(bool reconnect, global_seq, peer_global_seq, connect_seq, client_cookie, server_cookie, io_stat_printer{*this}); - execute_ready(false); + execute_ready(); }).handle_exception([this](std::exception_ptr eptr) { fault(state_t::REPLACING, "trigger_replacing", eptr); }); @@ -1924,20 +1931,11 @@ seastar::future<> ProtocolV2::read_message(utime_t throttle_stamp, std::size_t m }); } -void ProtocolV2::execute_ready(bool dispatch_connect) +void ProtocolV2::execute_ready() { ceph_assert_always(is_socket_valid); assert(conn.policy.lossy || (client_cookie != 0 && server_cookie != 0)); trigger_state(state_t::READY, out_state_t::open, false); - if (dispatch_connect) { - dispatchers.ms_handle_connect( - seastar::static_pointer_cast(conn.shared_from_this())); - if (unlikely(state != state_t::READY)) { - logger().debug("{} triggered {} after ms_handle_connect() during execute_ready()", - conn, get_state_name(state)); - abort_protocol(); - } - } #ifdef UNIT_TESTS_BUILT if (conn.interceptor) { conn.interceptor->register_conn_ready(conn); diff --git a/src/crimson/net/ProtocolV2.h b/src/crimson/net/ProtocolV2.h index 8b0d098a0fcc9..3b02b2f6a95b1 100644 --- a/src/crimson/net/ProtocolV2.h +++ b/src/crimson/net/ProtocolV2.h @@ -243,7 +243,7 @@ class ProtocolV2 final : public Protocol { // READY seastar::future<> read_message(utime_t throttle_stamp, std::size_t msg_size); - void execute_ready(bool dispatch_connect); + void execute_ready(); // STANDBY void execute_standby();