From: Yingxin Cheng Date: Tue, 6 Dec 2022 01:39:34 +0000 (+0800) Subject: crimson/net: drop Protocol::print_conn() X-Git-Tag: v18.1.0~375^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9fb5f249247b86ac63a2a9e3e76a4d2bc156d02c;p=ceph.git crimson/net: drop Protocol::print_conn() Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index b38f72539b5a3..3bc9e9641aa45 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -479,7 +479,7 @@ void Protocol::notify_out_dispatch() [[fallthrough]]; case out_state_t::delay: assert(!gate.is_closed()); - gate.dispatch_in_background("do_out_dispatch", *this, [this] { + gate.dispatch_in_background("do_out_dispatch", conn, [this] { return do_out_dispatch(); }); return; @@ -607,7 +607,7 @@ void Protocol::do_in_dispatch() { ceph_assert_always(!in_exit_dispatching.has_value()); in_exit_dispatching = seastar::promise<>(); - gate.dispatch_in_background("do_in_dispatch", *this, [this] { + gate.dispatch_in_background("do_in_dispatch", conn, [this] { return seastar::keep_doing([this] { return frame_assembler->read_main_preamble( ).then([this](auto ret) { diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index e6e6c956ea7e8..c9bf000c0d710 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -35,8 +35,6 @@ class Protocol { virtual void start_accept(SocketRef&& socket, const entity_addr_t& peer_addr) = 0; - virtual void print_conn(std::ostream&) const = 0; - protected: Protocol(ChainedDispatchers& dispatchers, SocketConnection& conn); @@ -209,11 +207,6 @@ class Protocol { clock_t::time_point last_keepalive_ack; }; -inline std::ostream& operator<<(std::ostream& out, const Protocol& proto) { - proto.print_conn(out); - return out; -} - inline std::ostream& operator<<( std::ostream& out, Protocol::io_stat_printer stat) { stat.protocol.print_io_stat(out); @@ -246,7 +239,3 @@ struct fmt::formatter return formatter::format(name, ctx); } }; - -#if FMT_VERSION >= 90000 -template <> struct fmt::formatter : fmt::ostream_formatter {}; -#endif diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index 13be01e32ded9..eb9c795f6590b 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -235,7 +235,7 @@ void ProtocolV2::trigger_state(state_t new_state, out_state_t _out_state, bool r */ if (pre_state == state_t::READY) { - gate.dispatch_in_background("exit_io", *this, [this] { + gate.dispatch_in_background("exit_io", conn, [this] { return wait_io_exit_dispatching( ).then([this](FrameAssemblerV2Ref fa) { frame_assembler = std::move(fa); @@ -781,7 +781,7 @@ void ProtocolV2::execute_connecting() { ceph_assert_always(!is_socket_valid); trigger_state(state_t::CONNECTING, out_state_t::delay, false); - gated_execute("execute_connecting", [this] { + gated_execute("execute_connecting", conn, [this] { global_seq = messenger.get_global_seq(); assert(client_cookie != 0); if (!conn.policy.lossy && server_cookie != 0) { @@ -817,7 +817,7 @@ void ProtocolV2::execute_connecting() } else { gate.dispatch_in_background( "replace_socket_connecting", - *this, + conn, [this, new_socket=std::move(new_socket)]() mutable { return frame_assembler->replace_shutdown_socket(std::move(new_socket)); } @@ -1469,7 +1469,7 @@ void ProtocolV2::execute_accepting() { assert(is_socket_valid); trigger_state(state_t::ACCEPTING, out_state_t::none, false); - gate.dispatch_in_background("execute_accepting", *this, [this] { + gate.dispatch_in_background("execute_accepting", conn, [this] { return seastar::futurize_invoke([this] { INTERCEPT_N_RW(custom_bp_t::SOCKET_ACCEPTED); auth_meta = seastar::make_lw_shared(); @@ -1602,7 +1602,7 @@ void ProtocolV2::execute_establishing(SocketConnectionRef existing_conn) { abort_protocol(); } - gated_execute("execute_establishing", [this] { + gated_execute("execute_establishing", conn, [this] { return seastar::futurize_invoke([this] { return send_server_ident(); }).then([this] { @@ -1688,16 +1688,18 @@ void ProtocolV2::trigger_replacing(bool reconnect, frame_assembler->shutdown_socket(); is_socket_valid = false; } - gate.dispatch_in_background("trigger_replacing", *this, - [this, - reconnect, - do_reset, - mover = std::move(mover), - new_auth_meta = std::move(new_auth_meta), - new_client_cookie, new_peer_name, - new_conn_features, new_peer_supported_features, - new_peer_global_seq, - new_connect_seq, new_msg_seq] () mutable { + gate.dispatch_in_background( + "trigger_replacing", + conn, + [this, + reconnect, + do_reset, + mover = std::move(mover), + new_auth_meta = std::move(new_auth_meta), + new_client_cookie, new_peer_name, + new_conn_features, new_peer_supported_features, + new_peer_global_seq, + new_connect_seq, new_msg_seq] () mutable { ceph_assert_always(state == state_t::REPLACING); dispatch_accept(); // state may become CLOSING, close mover.socket and abort later @@ -1732,7 +1734,7 @@ void ProtocolV2::trigger_replacing(bool reconnect, peer_global_seq = new_peer_global_seq; gate.dispatch_in_background( "replace_frame_assembler", - *this, + conn, [this, mover=std::move(mover)]() mutable { return frame_assembler->replace_by(std::move(mover)); } @@ -1815,7 +1817,7 @@ void ProtocolV2::execute_wait(bool max_backoff) { ceph_assert_always(!is_socket_valid); trigger_state(state_t::WAIT, out_state_t::delay, false); - gated_execute("execute_wait", [this, max_backoff] { + gated_execute("execute_wait", conn, [this, max_backoff] { double backoff = protocol_timer.last_dur(); if (max_backoff) { backoff = local_conf().get_val("ms_max_backoff"); @@ -1847,7 +1849,7 @@ void ProtocolV2::execute_server_wait() { ceph_assert_always(is_socket_valid); trigger_state(state_t::SERVER_WAIT, out_state_t::none, false); - gated_execute("execute_server_wait", [this] { + gated_execute("execute_server_wait", conn, [this] { return frame_assembler->read_exactly(1 ).then([this](auto bl) { logger().warn("{} SERVER_WAIT got read, abort", conn); @@ -1969,9 +1971,4 @@ void ProtocolV2::do_close( }); } -void ProtocolV2::print_conn(std::ostream& out) const -{ - out << conn; -} - } // namespace crimson::net diff --git a/src/crimson/net/ProtocolV2.h b/src/crimson/net/ProtocolV2.h index 807c63de5038e..e193e1c84c097 100644 --- a/src/crimson/net/ProtocolV2.h +++ b/src/crimson/net/ProtocolV2.h @@ -37,8 +37,6 @@ class ProtocolV2 final : public Protocol { void start_accept(SocketRef&& socket, const entity_addr_t& peer_addr) override; - void print_conn(std::ostream&) const final; - private: void notify_out() override; @@ -121,14 +119,14 @@ class ProtocolV2 final : public Protocol { seastar::future<> execution_done = seastar::now(); - template - void gated_execute(const char* what, Func&& func) { - gate.dispatch_in_background(what, *this, [this, &func] { + template + void gated_execute(const char *what, T &who, Func &&func) { + gate.dispatch_in_background(what, who, [this, &who, &func] { if (!execution_done.available()) { // discard the unready future gate.dispatch_in_background( "gated_execute_abandon", - *this, + who, [fut=std::move(execution_done)]() mutable { return std::move(fut); }