From f6565a62fb843befcec0069a4e5544779db1eadf Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Fri, 2 Jun 2023 18:09:18 +0800 Subject: [PATCH] crimson/net: expose the connection working shard to users Signed-off-by: Yingxin Cheng (cherry picked from commit b2a456d6b86e0105397f66fb1576acb37d650c56) --- src/crimson/net/Connection.h | 9 +++++++++ src/crimson/net/SocketConnection.h | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/crimson/net/Connection.h b/src/crimson/net/Connection.h index d8336e524313d..4339e41f0c2db 100644 --- a/src/crimson/net/Connection.h +++ b/src/crimson/net/Connection.h @@ -40,6 +40,15 @@ class Connection : public seastar::enable_shared_from_this { virtual ~Connection() {} + /** + * get_shard_id + * + * The shard id where the Connection is dispatching events and handling I/O. + * + * May be changed with the accept/connect events. + */ + virtual const seastar::shard_id get_shard_id() const = 0; + virtual const entity_name_t &get_peer_name() const = 0; entity_type_t get_peer_type() const { return get_peer_name().type(); } diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index 5fd70049aabd3..102e179583127 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -36,6 +36,8 @@ class Interceptor; * ConnectionHandler * * The interface class to implement Connection, called by SocketConnection. + * + * The operations must be done in get_shard_id(). */ class ConnectionHandler { public: @@ -69,13 +71,20 @@ protected: }; class SocketConnection : public Connection { - // Connection interfaces, public to users + /* + * Connection interfaces, public to users + * Working in ConnectionHandler::get_shard_id() + */ public: SocketConnection(SocketMessenger& messenger, ChainedDispatchers& dispatchers); ~SocketConnection() override; + const seastar::shard_id get_shard_id() const override { + return io_handler->get_shard_id(); + } + const entity_name_t &get_peer_name() const override { return peer_name; } -- 2.39.5