]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common: schedule action only if the future is not available 37698/head
authorKefu Chai <kchai@redhat.com>
Fri, 16 Oct 2020 14:07:50 +0000 (22:07 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 16 Oct 2020 14:08:03 +0000 (22:08 +0800)
otherwise we could call do_until() recursively if we have other tasks
which need to prempt the reactor and current future's state is actually
always available.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/errorator.h

index a52a711f9d1bbdff4d8792c7fbe3da77e696d85a..aef57cb9b3759e03fecec984bc5fc47e7158f768 100644 (file)
@@ -58,18 +58,19 @@ inline auto do_until(AsyncAction action) {
       return futurator::type::errorator_type::template make_exception_future2<>(
         f.get_exception()
       );
-    }
-    if (!f.available() || seastar::need_preempt()) {
+    } else if (f.available()) {
+      if (auto done = f.get0()) {
+        return futurator::type::errorator_type::template make_ready_future<>();
+      }
+    } else {
       return std::move(f)._then(
-        [ action = std::move(action)] (auto &&done) mutable {
-         if (done) {
-           return futurator::type::errorator_type::template make_ready_future<>();
-         }
+        [action = std::move(action)] (auto &&done) mutable {
+          if (done) {
+            return futurator::type::errorator_type::template make_ready_future<>();
+          }
           return ::crimson::do_until(
-           std::move(action));
-       });
-    } else if (bool stop_cond = f.get0()) {
-      return futurator::type::errorator_type::template make_ready_future<>();
+            std::move(action));
+        });
     }
   }
 }