]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/net: abort on-going v1 protocol when closed
authorYingxin Cheng <yingxin.cheng@intel.com>
Tue, 15 Dec 2020 07:52:08 +0000 (15:52 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 15 Dec 2020 07:55:05 +0000 (15:55 +0800)
Fixes: http://tracker.ceph.com/issues/48108
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/ProtocolV1.cc

index 5d04422da755cf66e378f0e04f0352a0b3d3d932..3c604240d5834583c37530093024845296bdba53 100644 (file)
@@ -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<SocketConnection>(conn.shared_from_this()));
           messenger.unaccept_conn(