From: Yingxin Cheng Date: Mon, 26 Aug 2019 03:35:55 +0000 (+0800) Subject: crimson/net: add Connection::is_closed() for tests X-Git-Tag: v15.1.0~1675^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=58dcc60c73ec3cc6463feea143c58b5124d817d7;p=ceph-ci.git crimson/net: add Connection::is_closed() for tests Tests need to introspect whether the connection is closed correctly. For normal users, ms_handle_reset() will notify them when a connection is closed by messenger. Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/Connection.h b/src/crimson/net/Connection.h index 328aca570d5..66dbb1dd669 100644 --- a/src/crimson/net/Connection.h +++ b/src/crimson/net/Connection.h @@ -59,6 +59,10 @@ class Connection : public seastar::enable_shared_from_this { /// true if the handshake has completed and no errors have been encountered virtual bool is_connected() const = 0; +#ifdef UNIT_TESTS_BUILT + virtual bool is_closed() const = 0; +#endif + /// send a message over a connection that has completed its handshake virtual seastar::future<> send(MessageRef msg) = 0; diff --git a/src/crimson/net/Protocol.h b/src/crimson/net/Protocol.h index f3a7443a12f..84c5f1f470c 100644 --- a/src/crimson/net/Protocol.h +++ b/src/crimson/net/Protocol.h @@ -24,6 +24,8 @@ class Protocol { bool is_connected() const; + bool is_closed() const { return closed; } + // Reentrant closing seastar::future<> close(); diff --git a/src/crimson/net/SocketConnection.cc b/src/crimson/net/SocketConnection.cc index 452754b3a55..4d78cb13dfd 100644 --- a/src/crimson/net/SocketConnection.cc +++ b/src/crimson/net/SocketConnection.cc @@ -47,6 +47,14 @@ bool SocketConnection::is_connected() const return protocol->is_connected(); } +#ifdef UNIT_TESTS_BUILT +bool SocketConnection::is_closed() const +{ + ceph_assert(seastar::engine().cpu_id() == shard_id()); + return protocol->is_closed(); +} +#endif + seastar::future<> SocketConnection::send(MessageRef msg) { // Cannot send msg from another core now, its ref counter can be contaminated! diff --git a/src/crimson/net/SocketConnection.h b/src/crimson/net/SocketConnection.h index 183fc81d94a..0c49f621b88 100644 --- a/src/crimson/net/SocketConnection.h +++ b/src/crimson/net/SocketConnection.h @@ -81,6 +81,10 @@ class SocketConnection : public Connection { bool is_connected() const override; +#ifdef UNIT_TESTS_BUILT + bool is_closed() const override; +#endif + seastar::future<> send(MessageRef msg) override; seastar::future<> keepalive() override;