]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: fix lambda captures of non-variables 32494/head
authorRonen Friedman <rfriedma@redhat.com>
Mon, 6 Jan 2020 07:46:49 +0000 (09:46 +0200)
committerRonen Friedman <rfriedma@redhat.com>
Tue, 7 Jan 2020 10:39:42 +0000 (12:39 +0200)
One cannot just capture a structured binding "non-variable".
(From the C++ standard, $8.4.5.2:
"If a lambda-expression [...] captures a structured binding (explicitly or implicitly),
the program is ill-formed.")

Co-authored-by: Kefu Chai <kchai@redhat.com>
Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/crimson/osd/main.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/crimson/osd/shard_services.cc

index 8d9152debd4acf885a1051b88d5ac68264fd7c85..4ffe64546824c3b66ad003460e3452ee11d7d2fc 100644 (file)
@@ -134,7 +134,8 @@ int main(int argc, char* argv[])
   using crimson::common::sharded_conf;
   using crimson::common::sharded_perf_coll;
   try {
-    return app.run_deprecated(app_args.size(), const_cast<char**>(app_args.data()), [&] {
+    return app.run_deprecated(app_args.size(), const_cast<char**>(app_args.data()),
+      [&, &ceph_args=ceph_args] {
       auto& config = app.configuration();
       return seastar::async([&] {
        if (config.count("debug")) {
index f66b7cacdb472da02f78803b8907f375e87cff03..28953c0bd03d18285799565f8d15952736aefd4a 100644 (file)
@@ -683,7 +683,7 @@ PG::get_locked_obc(
       auto &[head_obc, head_existed] = p;
       if (oid.is_head()) {
        if (head_existed) {
-         return head_obc->get_lock_type(op, type).then([head_obc] {
+         return head_obc->get_lock_type(op, type).then([head_obc=head_obc] {
            ceph_assert(head_obc->loaded);
            return load_obc_ertr::make_ready_future<ObjectContextRef>(head_obc);
          });
@@ -693,14 +693,14 @@ PG::get_locked_obc(
        }
       } else {
        return head_obc->get_lock_type(op, RWState::RWREAD).then(
-         [this, head_obc, op, oid, type] {
+         [this, head_obc=head_obc, op, oid, type] {
            ceph_assert(head_obc->loaded);
            return get_or_load_clone_obc(oid, head_obc);
-         }).safe_then([this, head_obc, op, oid, type](auto p) {
+         }).safe_then([this, head_obc=head_obc, op, oid, type](auto p) {
              auto &[obc, existed] = p;
              if (existed) {
                return load_obc_ertr::future<>(
-                 obc->get_lock_type(op, type)).safe_then([obc] {
+                 obc->get_lock_type(op, type)).safe_then([obc=obc] {
                  ceph_assert(obc->loaded);
                  return load_obc_ertr::make_ready_future<ObjectContextRef>(obc);
                });
@@ -708,7 +708,7 @@ PG::get_locked_obc(
                obc->degrade_excl_to(type);
                return load_obc_ertr::make_ready_future<ObjectContextRef>(obc);
              }
-         }).safe_then([head_obc](auto obc) {
+         }).safe_then([head_obc=head_obc](auto obc) {
            head_obc->put_lock_type(RWState::RWREAD);
            return load_obc_ertr::make_ready_future<ObjectContextRef>(obc);
          });
index 462d77a771b66ae1121f5527755ac5663aafc3c7..9374830c33a3598940b832b015fddfcff5c8845b 100644 (file)
@@ -467,8 +467,8 @@ public:
     F &&f) {
     auto [oid, type] = get_oid_and_lock(*m, op_info);
     return get_locked_obc(op, oid, type)
-      .safe_then([this, f=std::forward<F>(f), type](auto obc) {
-       return f(obc).finally([this, obc, type] {
+      .safe_then([this, f=std::forward<F>(f), type=type](auto obc) {
+       return f(obc).finally([this, obc, type=type] {
          obc->put_lock_type(type);
          return load_obc_ertr::now();
        });
index 818006a2901bbb8d5a28e08d30a7e8adf2b468a5..35d4f6d614a88114e10e4f5987da2bf7959d2c6e 100644 (file)
@@ -81,7 +81,8 @@ seastar::future<> ShardServices::dispatch_context_messages(
     [this](auto& osd_messages) {
       auto& [peer, messages] = osd_messages;
       logger().debug("dispatch_context_messages sending messages to {}", peer);
-      return seastar::parallel_for_each(std::move(messages), [=](auto& m) {
+      return seastar::parallel_for_each(
+        std::move(messages), [=, peer=peer](auto& m) {
         return send_to_osd(peer, m, osdmap->get_epoch());
       });
     });