From 9282d1a5d28e2bf92f06efacdd63c9965c2cf542 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Thu, 14 Feb 2019 16:44:20 +0800 Subject: [PATCH] crimson/net: introduce SocketFRef Signed-off-by: Yingxin Cheng --- src/crimson/net/Protocol.h | 4 ++-- src/crimson/net/ProtocolV1.cc | 2 +- src/crimson/net/ProtocolV1.h | 2 +- src/crimson/net/Socket.h | 4 ++++ src/crimson/net/SocketConnection.cc | 2 +- src/crimson/net/SocketConnection.h | 4 ++-- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index 6a0f76e88bcd4..4777af3c634fe 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -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>&& 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> socket; + SocketFRef socket; seastar::gate pending_dispatch; // write_state is changed with state atomically, indicating the write diff --git a/src/crimson/net/ProtocolV1.cc b/src/crimson/net/ProtocolV1.cc index cbfa4d28ee7c7..672e04c0f14e9 100644 --- a/src/crimson/net/ProtocolV1.cc +++ b/src/crimson/net/ProtocolV1.cc @@ -533,7 +533,7 @@ seastar::future ProtocolV1::repeat_handle_connect() }); } -void ProtocolV1::start_accept(seastar::foreign_ptr>&& sock, +void ProtocolV1::start_accept(SocketFRef&& sock, const entity_addr_t& _peer_addr) { ceph_assert(state == state_t::none); diff --git a/src/crimson/net/ProtocolV1.h b/src/crimson/net/ProtocolV1.h index 183c7e635bfc4..b3692a799c29b 100644 --- a/src/crimson/net/ProtocolV1.h +++ b/src/crimson/net/ProtocolV1.h @@ -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>&& socket, + void start_accept(SocketFRef&& socket, const entity_addr_t& peer_addr) override; void trigger_close() override; diff --git a/src/crimson/net/Socket.h b/src/crimson/net/Socket.h index c1a2ed59a4ce3..95fc78fbebef2 100644 --- a/src/crimson/net/Socket.h +++ b/src/crimson/net/Socket.h @@ -4,12 +4,16 @@ #pragma once #include +#include #include #include "include/buffer.h" namespace ceph::net { +class Socket; +using SocketFRef = seastar::foreign_ptr>; + class Socket { const seastar::shard_id sid; diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 9a547960a33a9..764457a8b8440 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -107,7 +107,7 @@ SocketConnection::start_connect(const entity_addr_t& _peer_addr, } void -SocketConnection::start_accept(seastar::foreign_ptr>&& sock, +SocketConnection::start_accept(SocketFRef&& sock, const entity_addr_t& _peer_addr) { protocol->start_accept(std::move(sock), _peer_addr); diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index a403b6790d313..a3c19ddd6df2e 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -18,12 +18,12 @@ #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; @@ -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>&& socket, + void start_accept(SocketFRef&& socket, const entity_addr_t& peer_addr); seq_num_t rx_seq_num() const { -- 2.39.5