]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: hide dispatchers from ProtocolV2
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 2 Dec 2022 09:21:58 +0000 (17:21 +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 e79795a7cd52ebf5fff6ab3d87de37945085e455..b20af96097bc66909c1dae8ab86bb26385bb9bd4 100644 (file)
@@ -269,6 +269,31 @@ void Protocol::reset_out()
   ack_left = 0;
 }
 
+void Protocol::dispatch_accept()
+{
+  dispatchers.ms_handle_accept(
+    seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+}
+
+void Protocol::dispatch_connect()
+{
+  dispatchers.ms_handle_connect(
+    seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+}
+
+void Protocol::dispatch_reset(bool is_replace)
+{
+  dispatchers.ms_handle_reset(
+    seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()),
+    is_replace);
+}
+
+void Protocol::dispatch_remote_reset()
+{
+  dispatchers.ms_handle_remote_reset(
+    seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+}
+
 void Protocol::ack_out_sent(seq_num_t seq)
 {
   if (conn.policy.lossy) {  // lossy connections don't keep sent messages
index 215c951331ec2e64dc27bc46aa50152b877508dd..c107bee66fd152f13a1b629e056358d6ed977b9a 100644 (file)
@@ -127,7 +127,13 @@ class Protocol {
     return in_seq;
   }
 
-  ChainedDispatchers& dispatchers;
+  void dispatch_accept();
+
+  void dispatch_connect();
+
+  void dispatch_reset(bool is_replace);
+
+  void dispatch_remote_reset();
 
  private:
   bool is_out_queued() const {
@@ -154,6 +160,8 @@ class Protocol {
 
   void do_in_dispatch();
 
+  ChainedDispatchers &dispatchers;
+
   SocketConnection &conn;
 
   crimson::common::Gated gate;
index a99dd0d4bf980b3489865077e49e065d504e75f0..875b3c257724d228d10fe207d17492062a8d320b 100644 (file)
@@ -13,7 +13,6 @@
 #include "crimson/auth/AuthServer.h"
 #include "crimson/common/formatter.h"
 
-#include "chained_dispatchers.h"
 #include "Errors.h"
 #include "SocketConnection.h"
 #include "SocketMessenger.h"
@@ -67,9 +66,9 @@ seastar::logger& logger() {
   throw std::system_error(make_error_code(crimson::net::error::protocol_aborted));
 }
 
-#define ABORT_IN_CLOSE(dispatch_reset) { \
-  do_close(dispatch_reset);              \
-  abort_protocol();                      \
+#define ABORT_IN_CLOSE(is_dispatch_reset) { \
+  do_close(is_dispatch_reset);              \
+  abort_protocol();                         \
 }
 
 inline void expect_tag(const Tag& expected,
@@ -363,8 +362,7 @@ void ProtocolV2::reset_session(bool full)
     client_cookie = generate_client_cookie();
     peer_global_seq = 0;
     reset_out();
-    dispatchers.ms_handle_remote_reset(
-       seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+    dispatch_remote_reset();
   }
 }
 
@@ -883,8 +881,7 @@ void ProtocolV2::execute_connecting()
                           conn, global_seq, peer_global_seq, connect_seq,
                           client_cookie, server_cookie,
                           io_stat_printer{*this});
-            dispatchers.ms_handle_connect(
-              seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+            dispatch_connect();
             if (unlikely(state != state_t::CONNECTING)) {
               logger().debug("{} triggered {} after ms_handle_connect(), abort",
                              conn, get_state_name(state));
@@ -1593,7 +1590,7 @@ void ProtocolV2::execute_establishing(SocketConnectionRef existing_conn) {
   trigger_state(state_t::ESTABLISHING, out_state_t::delay, false);
   if (existing_conn) {
     static_cast<ProtocolV2*>(existing_conn->protocol.get())->do_close(
-        true /* dispatch_reset */, std::move(accept_me));
+        true /* is_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!",
@@ -1604,8 +1601,7 @@ void ProtocolV2::execute_establishing(SocketConnectionRef existing_conn) {
     accept_me();
   }
 
-  dispatchers.ms_handle_accept(
-      seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+  dispatch_accept();
   if (unlikely(state != state_t::ESTABLISHING)) {
     logger().debug("{} triggered {} after ms_handle_accept() during execute_establishing()",
                    conn, get_state_name(state));
@@ -1709,8 +1705,7 @@ void ProtocolV2::trigger_replacing(bool reconnect,
                   new_peer_global_seq,
                   new_connect_seq, new_msg_seq] () mutable {
     ceph_assert_always(state == state_t::REPLACING);
-    dispatchers.ms_handle_accept(
-        seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()));
+    dispatch_accept();
     // state may become CLOSING, close mover.socket and abort later
     return wait_exit_io(
     ).then([this] {
@@ -1896,7 +1891,7 @@ seastar::future<> ProtocolV2::close_clean_yielded()
 }
 
 void ProtocolV2::do_close(
-    bool dispatch_reset,
+    bool is_dispatch_reset,
     std::optional<std::function<void()>> f_accept_new)
 {
   if (closed) {
@@ -1907,7 +1902,7 @@ void ProtocolV2::do_close(
 
   bool is_replace = f_accept_new ? true : false;
   logger().info("{} closing: reset {}, replace {}", conn,
-                dispatch_reset ? "yes" : "no",
+                is_dispatch_reset ? "yes" : "no",
                 is_replace ? "yes" : "no");
 
   /*
@@ -1946,10 +1941,8 @@ void ProtocolV2::do_close(
   auto gate_closed = gate.close();
   auto out_closed = close_out();
 
-  if (dispatch_reset) {
-    dispatchers.ms_handle_reset(
-        seastar::static_pointer_cast<SocketConnection>(conn.shared_from_this()),
-        is_replace);
+  if (is_dispatch_reset) {
+    dispatch_reset(is_replace);
   }
 
   // asynchronous operations
index d60b1be83b449e84e99f2c1f365a3d7f38ead597..12c1a63878acfc7859e813fff2bc3726eef3a1aa 100644 (file)
@@ -253,7 +253,7 @@ class ProtocolV2 final : public Protocol {
 
   // CLOSING
   // reentrant
-  void do_close(bool dispatch_reset,
+  void do_close(bool is_dispatch_reset,
                 std::optional<std::function<void()>> f_accept_new=std::nullopt);
 };