]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/omap_manager: fix a capture-by-reference related issue
authorXuehan Xu <xxhdx1985126@gmail.com>
Sat, 14 Jan 2023 01:09:45 +0000 (09:09 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Mon, 16 Jan 2023 06:36:33 +0000 (14:36 +0800)
Variables that are not guaranteed to be available as long as the continuations
live shouldn't be captured by reference

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/os/seastore/omap_manager.h
src/crimson/os/seastore/omap_manager/btree/btree_omap_manager.cc

index 2eb5d89f4ae1f9964a04a343b838b33983bb0ac4..fc4e03e2b9d2534d2206b386292aa58d6304ef27 100644 (file)
@@ -175,8 +175,8 @@ public:
    *
    * @param omap_root_t &omap_root,  omap btree root information
    * @param Transaction &t,  current transaction
-   * @param string &first, range start,  must alive during the call
-   * @param string &last, range end,  must alive during the call
+   * @param string &first, range start
+   * @param string &last, range end
    */
   using omap_rm_key_range_iertr = base_iertr;
   using omap_rm_key_range_ret = omap_rm_key_range_iertr::future<>;
index 300eed4eac1ebffd4053b41b66139533cea59cf8..1782d7ee66ef9f83a6ecec9db62a40b07ec780c4 100644 (file)
@@ -198,13 +198,17 @@ BtreeOMapManager::omap_rm_key_range(
   LOG_PREFIX(BtreeOMapManager::omap_rm_key_range);
   DEBUGT("{} ~ {}", t, first, last);
   assert(first <= last);
-  return omap_list(
-    omap_root,
-    t,
-    first,
-    last,
-    config
-  ).si_then([this, &omap_root, &t](auto results) {
+  return seastar::do_with(
+    std::make_optional<std::string>(first),
+    std::make_optional<std::string>(last),
+    [this, &omap_root, &t, config](auto &first, auto &last) {
+    return omap_list(
+      omap_root,
+      t,
+      first,
+      last,
+      config);
+  }).si_then([this, &omap_root, &t](auto results) {
     LOG_PREFIX(BtreeOMapManager::omap_rm_key_range);
     auto &[complete, kvs] = results;
     std::vector<std::string> keys;