]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: proper group SocketConnection interfaces
authorYingxin Cheng <yingxin.cheng@intel.com>
Mon, 31 Oct 2022 09:32:53 +0000 (17:32 +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/ProtocolV2.cc
src/crimson/net/SocketConnection.h

index caa19da1e5f61c3c9d8240002b94fc106da3f7cc..11fdbbcd5c5942238284be8837454dc3e57c8a8a 100644 (file)
@@ -111,20 +111,25 @@ template <typename T> auto ptr(const ::seastar::shared_ptr<T>& p) -> const void*
 namespace crimson::net {
 
 #ifdef UNIT_TESTS_BUILT
-void intercept(Breakpoint bp, bp_type_t type,
-               SocketConnection& conn, SocketRef& socket) {
-  if (conn.interceptor) {
-    auto action = conn.interceptor->intercept(conn, Breakpoint(bp));
-    socket->set_trap(type, action, &conn.interceptor->blocker);
+void intercept(Breakpoint bp,
+               bp_type_t type,
+               Connection& conn,
+               Interceptor *interceptor,
+               SocketRef& socket) {
+  if (interceptor) {
+    auto action = interceptor->intercept(conn, Breakpoint(bp));
+    socket->set_trap(type, action, &interceptor->blocker);
   }
 }
 
 #define INTERCEPT_CUSTOM(bp, type)       \
-intercept({bp}, type, conn, conn.socket)
+intercept({bp}, type, conn,              \
+          conn.interceptor, conn.socket)
 
 #define INTERCEPT_FRAME(tag, type)       \
 intercept({static_cast<Tag>(tag), type}, \
-          type, conn, conn.socket)
+          type, conn,                    \
+          conn.interceptor, conn.socket)
 
 #define INTERCEPT_N_RW(bp)                               \
 if (conn.interceptor) {                                  \
index d4cbca463d30bbb1220bea1806465b7baef330ab..5a698919f28f73fdb976c1634df3794bfc569809 100644 (file)
@@ -59,10 +59,6 @@ class SocketConnection : public Connection {
   seq_num_t out_seq = 0;
   /// the seq num of the last received message
   seq_num_t in_seq = 0;
-  /// update the seq num of last received message
-  /// @returns true if the @c seq is valid, and @c in_seq is updated,
-  ///          false otherwise.
-  bool update_rx_seq(seq_num_t seq);
 
   // messages to be resent after connection gets reset
   std::deque<MessageURef> out_q;
@@ -73,8 +69,7 @@ class SocketConnection : public Connection {
 
   std::unique_ptr<user_private_t> user_private;
 
-  seastar::shard_id shard_id() const;
-
+ // Connection interfaces, public to users
  public:
   SocketConnection(SocketMessenger& messenger,
                    ChainedDispatchers& dispatchers);
@@ -133,7 +128,34 @@ class SocketConnection : public Connection {
 
   void print(std::ostream& out) const override;
 
+ // public to SocketMessenger
  public:
+  /// start a handshake from the client's perspective,
+  /// only call when SocketConnection first construct
+  void start_connect(const entity_addr_t& peer_addr,
+                     const entity_name_t& peer_name);
+
+  /// start a handshake from the server's perspective,
+  /// only call when SocketConnection first construct
+  void start_accept(SocketRef&& socket,
+                    const entity_addr_t& peer_addr);
+
+  seastar::future<> close_clean(bool dispatch_reset);
+
+  seastar::socket_address get_local_address() const;
+
+  SocketMessenger &get_messenger() const {
+    return messenger;
+  }
+
+private:
+  seastar::shard_id shard_id() const;
+
+  /// update the seq num of last received message
+  /// @returns true if the @c seq is valid, and @c in_seq is updated,
+  ///          false otherwise.
+  bool update_rx_seq(seq_num_t seq);
+
   void set_peer_type(entity_type_t peer_type) {
     // it is not allowed to assign an unknown value when the current
     // value is known
@@ -173,31 +195,6 @@ class SocketConnection : public Connection {
     features = f;
   }
 
-  /// start a handshake from the client's perspective,
-  /// only call when SocketConnection first construct
-  void start_connect(const entity_addr_t& peer_addr,
-                     const entity_name_t& peer_name);
-  /// start a handshake from the server's perspective,
-  /// only call when SocketConnection first construct
-  void start_accept(SocketRef&& socket,
-                    const entity_addr_t& peer_addr);
-
-  seastar::future<> close_clean(bool dispatch_reset);
-
-  bool is_server_side() const {
-    return policy.server;
-  }
-
-  bool is_lossy() const {
-    return policy.lossy;
-  }
-
-  seastar::socket_address get_local_address() const;
-
-  SocketMessenger &get_messenger() const {
-    return messenger;
-  }
-
 #ifdef UNIT_TESTS_BUILT
   bool is_closed_clean() const override;