]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: all interruptible future invocations should have already had interrup... 42841/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Mon, 23 Aug 2021 05:59:13 +0000 (13:59 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Mon, 23 Aug 2021 10:23:41 +0000 (18:23 +0800)
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/common/interruptible_future.h

index 81cadb98d6dcdc3edfb21d3d4819703e12d281ef..c098a451499f1c2b4d7ba9a45e45f2910bade999 100644 (file)
@@ -154,30 +154,29 @@ auto call_with_interruption_impl(
   // need to be interrupted, return an interruption; otherwise, restore the
   // global "interrupt_cond" with the interruption condition, and go ahead
   // executing the Func.
-  if (interrupt_condition) {
-    auto [interrupt, fut] = interrupt_condition->template may_interrupt<
-      typename futurator_t::type>();
-    INTR_FUT_DEBUG(
-      "call_with_interruption_impl: may_interrupt: {}, "
-      "local interrupt_condintion: {}, "
-      "global interrupt_cond: {},{}",
-      interrupt,
-      (void*)interrupt_condition.get(),
-      (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
-      typeid(InterruptCond).name());
-    if (interrupt) {
-      return std::move(*fut);
-    }
-    interrupt_cond<InterruptCond>.set(interrupt_condition);
-  }
-
-  auto fut = seastar::futurize_invoke(
+  assert(interrupt_condition);
+  auto [interrupt, fut] = interrupt_condition->template may_interrupt<
+    typename futurator_t::type>();
+  INTR_FUT_DEBUG(
+    "call_with_interruption_impl: may_interrupt: {}, "
+    "local interrupt_condintion: {}, "
+    "global interrupt_cond: {},{}",
+    interrupt,
+    (void*)interrupt_condition.get(),
+    (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+    typeid(InterruptCond).name());
+  if (interrupt) {
+    return std::move(*fut);
+  }
+  interrupt_cond<InterruptCond>.set(interrupt_condition);
+
+  auto fut2 = seastar::futurize_invoke(
       std::forward<Func>(func),
       std::forward<Args>(args)...);
   // Clear the global "interrupt_cond" to prevent it from interfering other
   // continuation chains.
   interrupt_cond<InterruptCond>.reset();
-  return fut;
+  return fut2;
 }
 
 }
@@ -256,20 +255,19 @@ Result non_futurized_call_with_interruption(
   InterruptCondRef<InterruptCond> interrupt_condition,
   Func&& func, T&&... args)
 {
-  if (interrupt_condition) {
-    auto [interrupt, fut] = interrupt_condition->template may_interrupt<seastar::future<>>();
-    INTR_FUT_DEBUG(
-      "non_futurized_call_with_interruption may_interrupt: {}, "
-      "interrupt_condition: {}, interrupt_cond: {},{}",
-      interrupt,
-      (void*)interrupt_condition.get(),
-      (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
-      typeid(InterruptCond).name());
-    if (interrupt) {
-      std::rethrow_exception(fut->get_exception());
-    }
-    interrupt_cond<InterruptCond>.set(interrupt_condition);
-  }
+  assert(interrupt_condition);
+  auto [interrupt, fut] = interrupt_condition->template may_interrupt<seastar::future<>>();
+  INTR_FUT_DEBUG(
+    "non_futurized_call_with_interruption may_interrupt: {}, "
+    "interrupt_condition: {}, interrupt_cond: {},{}",
+    interrupt,
+    (void*)interrupt_condition.get(),
+    (void*)interrupt_cond<InterruptCond>.interrupt_cond.get(),
+    typeid(InterruptCond).name());
+  if (interrupt) {
+    std::rethrow_exception(fut->get_exception());
+  }
+  interrupt_cond<InterruptCond>.set(interrupt_condition);
   try {
     if constexpr (std::is_void_v<Result>) {
       std::invoke(std::forward<Func>(func), std::forward<T>(args)...);