]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: drop Protocol::proto_type
authorYingxin Cheng <yingxin.cheng@intel.com>
Tue, 18 Oct 2022 08:23:01 +0000 (16:23 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 20 Oct 2022 03:01:00 +0000 (11:01 +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 fe5189bb7759552f5533dfa48609811fcca0ea1c..97f48ab91ba72a24044b0d936a16d92de5ae29e2 100644 (file)
@@ -20,11 +20,9 @@ namespace {
 
 namespace crimson::net {
 
-Protocol::Protocol(proto_t type,
-                   ChainedDispatchers& dispatchers,
+Protocol::Protocol(ChainedDispatchers& dispatchers,
                    SocketConnection& conn)
-  : proto_type(type),
-    dispatchers(dispatchers),
+  : dispatchers(dispatchers),
     conn(conn)
 {}
 
index e34d2d1d11bf855a75baad6ee73395b80ba2ec55..83f5bf19b9149fbb467905518b9277fec1c93362 100644 (file)
@@ -16,12 +16,6 @@ namespace crimson::net {
 
 class Protocol {
  public:
-  enum class proto_t {
-    none,
-    v1,
-    v2
-  };
-
   Protocol(Protocol&&) = delete;
   virtual ~Protocol();
 
@@ -57,8 +51,7 @@ class Protocol {
 
   virtual void print(std::ostream&) const = 0;
  protected:
-  Protocol(proto_t type,
-           ChainedDispatchers& dispatchers,
+  Protocol(ChainedDispatchers& dispatchers,
            SocketConnection& conn);
 
   virtual void trigger_close() = 0;
@@ -82,7 +75,6 @@ class Protocol {
       bool require_ack); 
 
  public:
-  const proto_t proto_type;
   SocketRef socket;
 
  protected:
index d70b01147145bead71663a2c8ade6989412ecc68..3bacb48c9572bab75e0e890592e0f428cc71dabe 100644 (file)
@@ -151,7 +151,7 @@ seastar::future<> ProtocolV2::Timer::backoff(double seconds)
 ProtocolV2::ProtocolV2(ChainedDispatchers& dispatchers,
                        SocketConnection& conn,
                        SocketMessenger& messenger)
-  : Protocol(proto_t::v2, dispatchers, conn),
+  : Protocol(dispatchers, conn),
     messenger{messenger},
     auth_meta{seastar::make_lw_shared<AuthConnectionMeta>()},
     protocol_timer{conn}
@@ -1137,7 +1137,7 @@ ProtocolV2::handle_existing_connection(SocketConnectionRef existing_conn)
     logger().warn("{} server_connect:"
                   " existing connection {} is a lossy channel. Close existing in favor of"
                   " this connection", conn, *existing_conn);
-    execute_establishing(existing_conn, true);
+    execute_establishing(existing_conn);
     return seastar::make_ready_future<next_step_t>(next_step_t::ready);
   }
 
@@ -1258,19 +1258,9 @@ ProtocolV2::server_connect()
     SocketConnectionRef existing_conn = messenger.lookup_conn(conn.peer_addr);
 
     if (existing_conn) {
-      if (existing_conn->protocol->proto_type != proto_t::v2) {
-        logger().warn("{} existing connection {} proto version is {}, close existing",
-                      conn, *existing_conn,
-                      static_cast<int>(existing_conn->protocol->proto_type));
-        // should unregister the existing from msgr atomically
-        // NOTE: this is following async messenger logic, but we may miss the reset event.
-        execute_establishing(existing_conn, false);
-        return seastar::make_ready_future<next_step_t>(next_step_t::ready);
-      } else {
-        return handle_existing_connection(existing_conn);
-      }
+      return handle_existing_connection(existing_conn);
     } else {
-      execute_establishing(nullptr, true);
+      execute_establishing(nullptr);
       return seastar::make_ready_future<next_step_t>(next_step_t::ready);
     }
   });
@@ -1364,16 +1354,6 @@ ProtocolV2::server_reconnect()
       return send_reset(true);
     }
 
-    if (existing_conn->protocol->proto_type != proto_t::v2) {
-      logger().warn("{} server_reconnect: existing connection {} proto version is {},"
-                    "close existing and reset client.",
-                    conn, *existing_conn,
-                    static_cast<int>(existing_conn->protocol->proto_type));
-      // NOTE: this is following async messenger logic, but we may miss the reset event.
-      existing_conn->mark_down();
-      return send_reset(true);
-    }
-
     ProtocolV2 *existing_proto = dynamic_cast<ProtocolV2*>(
         existing_conn->protocol.get());
     ceph_assert(existing_proto);
@@ -1574,8 +1554,7 @@ seastar::future<> ProtocolV2::finish_auth()
 
 // ESTABLISHING
 
-void ProtocolV2::execute_establishing(
-    SocketConnectionRef existing_conn, bool dispatch_reset) {
+void ProtocolV2::execute_establishing(SocketConnectionRef existing_conn) {
   if (unlikely(state != state_t::ACCEPTING)) {
     logger().debug("{} triggered {} before execute_establishing()",
                    conn, get_state_name(state));
@@ -1593,7 +1572,8 @@ void ProtocolV2::execute_establishing(
 
   trigger_state(state_t::ESTABLISHING, write_state_t::delay, false);
   if (existing_conn) {
-    existing_conn->protocol->close(dispatch_reset, std::move(accept_me));
+    existing_conn->protocol->close(
+        true /* dispatch_reset */, std::move(accept_me));
     if (unlikely(state != state_t::ESTABLISHING)) {
       logger().warn("{} triggered {} during execute_establishing(), "
                     "the accept event will not be delivered!",
index df5e7bbb4bfa4a2a0ea1c97c329e64b60206e543..fa76544e72a2145431dd311e83e3d183b1a7f605 100644 (file)
@@ -196,7 +196,7 @@ class ProtocolV2 final : public Protocol {
   seastar::future<> finish_auth();
 
   // ESTABLISHING
-  void execute_establishing(SocketConnectionRef existing_conn, bool dispatch_reset);
+  void execute_establishing(SocketConnectionRef existing_conn);
 
   // ESTABLISHING/REPLACING (server)
   seastar::future<> send_server_ident();