From 2015d5b3da515242712953d339c743c8a9fe174c Mon Sep 17 00:00:00 2001 From: Yingxin Cheng Date: Tue, 15 Dec 2020 15:52:08 +0800 Subject: [PATCH] crimson/net: abort on-going v1 protocol when closed Fixes: http://tracker.ceph.com/issues/48108 Signed-off-by: Yingxin Cheng --- src/crimson/net/ProtocolV1.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/crimson/net/ProtocolV1.cc b/src/crimson/net/ProtocolV1.cc index 5d04422da755c..3c604240d5834 100644 --- a/src/crimson/net/ProtocolV1.cc +++ b/src/crimson/net/ProtocolV1.cc @@ -327,7 +327,8 @@ void ProtocolV1::start_connect(const entity_addr_t& _peer_addr, return Socket::connect(conn.peer_addr) .then([this](SocketRef sock) { socket = std::move(sock); - if (state == state_t::closing) { + if (state != state_t::connecting) { + assert(state == state_t::closing); return socket->close().then([] { throw std::system_error(make_error_code(error::protocol_aborted)); }); @@ -353,6 +354,7 @@ void ProtocolV1::start_connect(const entity_addr_t& _peer_addr, make_error_code(crimson::net::error::bad_peer_address)); } if (state != state_t::connecting) { + assert(state == state_t::closing); throw std::system_error(make_error_code(error::protocol_aborted)); } socket->learn_ephemeral_port_as_connector(caddr.get_port()); @@ -375,6 +377,10 @@ void ProtocolV1::start_connect(const entity_addr_t& _peer_addr, return repeat_connect(); }); }).then([this] { + if (state != state_t::connecting) { + assert(state == state_t::closing); + throw std::system_error(make_error_code(error::protocol_aborted)); + } execute_open(open_t::connected); }).handle_exception([this] (std::exception_ptr eptr) { // TODO: handle fault in the connecting state @@ -684,6 +690,10 @@ void ProtocolV1::start_accept(SocketRef&& sock, return repeat_handle_connect(); }); }).then([this] { + if (state != state_t::accepting) { + assert(state == state_t::closing); + throw std::system_error(make_error_code(error::protocol_aborted)); + } messenger.register_conn( seastar::static_pointer_cast(conn.shared_from_this())); messenger.unaccept_conn( -- 2.39.5