From 6631e3dc01b4844c42c4c797eeff9456757c0672 Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Mon, 26 Aug 2019 11:14:48 +0800 Subject: [PATCH] crimson/net: return bool from Connection::is_connected() There's no need to return a futurized bool from is_connected() if we are holding ConnectionRef from the same core. Also add the missing const qualifier. Signed-off-by: Yingxin Cheng --- src/crimson/net/Connection.h | 2 +- src/crimson/net/SocketConnection.cc | 7 +++---- src/crimson/net/SocketConnection.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/crimson/net/Connection.h b/src/crimson/net/Connection.h index 0f8fb12204d..328aca570d5 100644 --- a/src/crimson/net/Connection.h +++ b/src/crimson/net/Connection.h @@ -57,7 +57,7 @@ class Connection : public seastar::enable_shared_from_this { bool peer_is_client() const { return peer_name.is_client(); } /// true if the handshake has completed and no errors have been encountered - virtual seastar::future is_connected() = 0; + virtual bool is_connected() const = 0; /// send a message over a connection that has completed its handshake virtual seastar::future<> send(MessageRef msg) = 0; diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index bb66a3e524a..452754b3a55 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -41,11 +41,10 @@ SocketConnection::get_messenger() const { return &messenger; } -seastar::future SocketConnection::is_connected() +bool SocketConnection::is_connected() const { - return seastar::smp::submit_to(shard_id(), [this] { - return protocol->is_connected(); - }); + ceph_assert(seastar::engine().cpu_id() == shard_id()); + return protocol->is_connected(); } seastar::future<> SocketConnection::send(MessageRef msg) diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index a8c4942ed0e..183fc81d94a 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -79,7 +79,7 @@ class SocketConnection : public Connection { Messenger* get_messenger() const override; - seastar::future is_connected() override; + bool is_connected() const override; seastar::future<> send(MessageRef msg) override; -- 2.39.5