crimson/net: introduce SocketFRef
authorYingxin Cheng <yingxincheng@gmail.com>
Thu, 14 Feb 2019 08:44:20 +0000 (16:44 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 5 Apr 2019 02:48:50 +0000 (10:48 +0800)
Signed-off-by: Yingxin Cheng <yingxincheng@gmail.com>
src/crimson/net/Protocol.h
src/crimson/net/ProtocolV1.cc
src/crimson/net/ProtocolV1.h
src/crimson/net/Socket.h
src/crimson/net/SocketConnection.cc
src/crimson/net/SocketConnection.h

index 6a0f76e88bcd4b9644eb427bbe4699348f3588d1..4777af3c634fe85f218596de2097667b1046240b 100644 (file)
@@ -28,7 +28,7 @@ class Protocol {
   virtual void start_connect(const entity_addr_t& peer_addr,
                              const entity_type_t& peer_type) = 0;
 
-  virtual void start_accept(seastar::foreign_ptr<std::unique_ptr<Socket>>&& socket,
+  virtual void start_accept(SocketFRef&& socket,
                             const entity_addr_t& peer_addr) = 0;
 
  protected:
@@ -52,7 +52,7 @@ class Protocol {
   Dispatcher &dispatcher;
   SocketConnection &conn;
 
-  seastar::foreign_ptr<std::unique_ptr<Socket>> socket;
+  SocketFRef socket;
   seastar::gate pending_dispatch;
 
   // write_state is changed with state atomically, indicating the write
index cbfa4d28ee7c7f1b5861b893a4dd094b5a0ff023..672e04c0f14e9192653645cf2eff40bfe45b69fd 100644 (file)
@@ -533,7 +533,7 @@ seastar::future<stop_t> ProtocolV1::repeat_handle_connect()
     });
 }
 
-void ProtocolV1::start_accept(seastar::foreign_ptr<std::unique_ptr<Socket>>&& sock,
+void ProtocolV1::start_accept(SocketFRef&& sock,
                               const entity_addr_t& _peer_addr)
 {
   ceph_assert(state == state_t::none);
index 183c7e635bfc4d45cd29437074a41abd05cf658b..b3692a799c29bac571d535e84e2d867d94f233c5 100644 (file)
@@ -21,7 +21,7 @@ class ProtocolV1 final : public Protocol {
   void start_connect(const entity_addr_t& peer_addr,
                      const entity_type_t& peer_type) override;
 
-  void start_accept(seastar::foreign_ptr<std::unique_ptr<Socket>>&& socket,
+  void start_accept(SocketFRef&& socket,
                     const entity_addr_t& peer_addr) override;
 
   void trigger_close() override;
index c1a2ed59a4ce34d103c36aff7799f5fe1790c673..95fc78fbebef29ee77ffaba73ef92329d31f96a1 100644 (file)
@@ -4,12 +4,16 @@
 #pragma once
 
 #include <seastar/core/reactor.hh>
+#include <seastar/core/sharded.hh>
 #include <seastar/net/packet.hh>
 
 #include "include/buffer.h"
 
 namespace ceph::net {
 
+class Socket;
+using SocketFRef = seastar::foreign_ptr<std::unique_ptr<Socket>>;
+
 class Socket
 {
   const seastar::shard_id sid;
index 9a547960a33a9267a273c6031041966fcfe52747..764457a8b84401fc406f743380a5b31ac63d5b4c 100644 (file)
@@ -107,7 +107,7 @@ SocketConnection::start_connect(const entity_addr_t& _peer_addr,
 }
 
 void
-SocketConnection::start_accept(seastar::foreign_ptr<std::unique_ptr<Socket>>&& sock,
+SocketConnection::start_accept(SocketFRef&& sock,
                                const entity_addr_t& _peer_addr)
 {
   protocol->start_accept(std::move(sock), _peer_addr);
index a403b6790d313960de39c1797ee0e70f06b17a4f..a3c19ddd6df2ed9ab6636cf2aad8a95930c40339 100644 (file)
 
 #include "msg/Policy.h"
 #include "Connection.h"
+#include "Socket.h"
 #include "crimson/thread/Throttle.h"
 
 namespace ceph::net {
 
 class Protocol;
-class Socket;
 class SocketMessenger;
 class SocketConnection;
 using SocketConnectionRef = seastar::shared_ptr<SocketConnection>;
@@ -92,7 +92,7 @@ class SocketConnection : public Connection {
                      const entity_type_t& peer_type);
   /// start a handshake from the server's perspective,
   /// only call when SocketConnection first construct
-  void start_accept(seastar::foreign_ptr<std::unique_ptr<Socket>>&& socket,
+  void start_accept(SocketFRef&& socket,
                     const entity_addr_t& peer_addr);
 
   seq_num_t rx_seq_num() const {