From: Yingxin Cheng Date: Tue, 15 Dec 2020 07:48:43 +0000 (+0800) Subject: crimson/net: report unexpected exceptions during closing X-Git-Tag: v16.1.0~249^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9856769098a20d4a7ff10699d263068a55fdc0b1;p=ceph.git crimson/net: report unexpected exceptions during closing Signed-off-by: Yingxin Cheng --- diff --git a/src/crimson/net/Protocol.cc b/src/crimson/net/Protocol.cc index 4c9c1846ce9d..50b5c45a335f 100644 --- a/src/crimson/net/Protocol.cc +++ b/src/crimson/net/Protocol.cc @@ -48,18 +48,6 @@ void Protocol::close(bool dispatch_reset, dispatch_reset ? "yes" : "no", is_replace ? "yes" : "no"); - // unregister_conn() drops a reference, so hold another until completion - auto cleanup = [conn_ref = conn.shared_from_this(), this] { - logger().debug("{} closed!", conn); - on_closed(); -#ifdef UNIT_TESTS_BUILT - is_closed_clean = true; - if (conn.interceptor) { - conn.interceptor->register_conn_closed(conn); - } -#endif - }; - // atomic operations closed = true; trigger_close(); @@ -87,7 +75,19 @@ void Protocol::close(bool dispatch_reset, } else { return seastar::now(); } - }).finally(std::move(cleanup)); + }).then([this] { + logger().debug("{} closed!", conn); + on_closed(); +#ifdef UNIT_TESTS_BUILT + is_closed_clean = true; + if (conn.interceptor) { + conn.interceptor->register_conn_closed(conn); + } +#endif + }).handle_exception([conn_ref = conn.shared_from_this(), this] (auto eptr) { + logger().error("{} closing: close_ready got unexpected exception {}", conn, eptr); + ceph_abort(); + }); } seastar::future<> Protocol::send(MessageRef msg) diff --git a/src/crimson/net/ProtocolV2.cc b/src/crimson/net/ProtocolV2.cc index bf9224b1712a..b7137b8b83b9 100644 --- a/src/crimson/net/ProtocolV2.cc +++ b/src/crimson/net/ProtocolV2.cc @@ -2103,6 +2103,10 @@ void ProtocolV2::execute_server_wait() void ProtocolV2::trigger_close() { + messenger.closing_conn( + seastar::static_pointer_cast( + conn.shared_from_this())); + if (state == state_t::ACCEPTING || state == state_t::SERVER_WAIT) { messenger.unaccept_conn( seastar::static_pointer_cast( @@ -2117,9 +2121,6 @@ void ProtocolV2::trigger_close() } protocol_timer.cancel(); - messenger.closing_conn( - seastar::static_pointer_cast( - conn.shared_from_this())); trigger_state(state_t::CLOSING, write_state_t::drop, false); }