]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: report unexpected exceptions during closing
authorYingxin Cheng <yingxin.cheng@intel.com>
Tue, 15 Dec 2020 07:48:43 +0000 (15:48 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Tue, 15 Dec 2020 07:48:43 +0000 (15:48 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/Protocol.cc
src/crimson/net/ProtocolV2.cc

index 4c9c1846ce9d81a36792649ee52b391dc6194b72..50b5c45a335f7eda571e5d654be9bd957b1dd65d 100644 (file)
@@ -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)
index bf9224b1712a7ddaabfd29ed7e6492d20710bf76..b7137b8b83b94727c8ad1cae1e19a583b1024fa9 100644 (file)
@@ -2103,6 +2103,10 @@ void ProtocolV2::execute_server_wait()
 
 void ProtocolV2::trigger_close()
 {
+  messenger.closing_conn(
+      seastar::static_pointer_cast<SocketConnection>(
+        conn.shared_from_this()));
+
   if (state == state_t::ACCEPTING || state == state_t::SERVER_WAIT) {
     messenger.unaccept_conn(
       seastar::static_pointer_cast<SocketConnection>(
@@ -2117,9 +2121,6 @@ void ProtocolV2::trigger_close()
   }
 
   protocol_timer.cancel();
-  messenger.closing_conn(
-      seastar::static_pointer_cast<SocketConnection>(
-       conn.shared_from_this()));
   trigger_state(state_t::CLOSING, write_state_t::drop, false);
 }