]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: drop Protocol::print_conn()
authorYingxin Cheng <yingxin.cheng@intel.com>
Tue, 6 Dec 2022 01:39:34 +0000 (09:39 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Wed, 8 Feb 2023 06:07:41 +0000 (14:07 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/Protocol.cc
src/crimson/net/Protocol.h
src/crimson/net/ProtocolV2.cc
src/crimson/net/ProtocolV2.h

index b38f72539b5a3032a43afe0590e0201e593b727f..3bc9e9641aa4589f6ba1fc9ac541c8cea6440938 100644 (file)
@@ -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) {
index e6e6c956ea7e80cd10ce2db17146d8e98c3e2aed..c9bf000c0d710a6d97038dd898c83a2218c592f2 100644 (file)
@@ -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<crimson::net::Protocol::out_state_t>
     return formatter<string_view>::format(name, ctx);
   }
 };
-
-#if FMT_VERSION >= 90000
-template <> struct fmt::formatter<crimson::net::Protocol> : fmt::ostream_formatter {};
-#endif
index 13be01e32ded9021647114c340aac9f441b5d275..eb9c795f6590b0a962fc5ffb72984307e255152a 100644 (file)
@@ -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<AuthConnectionMeta>();
@@ -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<double>("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
index 807c63de5038ef553a15e8fa24892f43686bf2dc..e193e1c84c097167471dddb66c246c87d596d5bb 100644 (file)
@@ -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 <typename Func>
-  void gated_execute(const char* what, Func&& func) {
-    gate.dispatch_in_background(what, *this, [this, &func] {
+  template <typename Func, typename T>
+  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);
           }