From 24694e2a064e4b4ce5c4bbefcf4e57744e1af2a1 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Mon, 6 Jan 2020 09:46:49 +0200 Subject: [PATCH] crimson: fix lambda captures of non-variables 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 Signed-off-by: Ronen Friedman --- src/crimson/osd/main.cc | 3 ++- src/crimson/osd/pg.cc | 10 +++++----- src/crimson/osd/pg.h | 4 ++-- src/crimson/osd/shard_services.cc | 3 ++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/crimson/osd/main.cc b/src/crimson/osd/main.cc index 8d9152debd4..4ffe6454682 100644 --- a/src/crimson/osd/main.cc +++ b/src/crimson/osd/main.cc @@ -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(app_args.data()), [&] { + return app.run_deprecated(app_args.size(), const_cast(app_args.data()), + [&, &ceph_args=ceph_args] { auto& config = app.configuration(); return seastar::async([&] { if (config.count("debug")) { diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index f66b7cacdb4..28953c0bd03 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -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(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(obc); }); @@ -708,7 +708,7 @@ PG::get_locked_obc( obc->degrade_excl_to(type); return load_obc_ertr::make_ready_future(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(obc); }); diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 462d77a771b..9374830c33a 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -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), type](auto obc) { - return f(obc).finally([this, obc, type] { + .safe_then([this, f=std::forward(f), type=type](auto obc) { + return f(obc).finally([this, obc, type=type] { obc->put_lock_type(type); return load_obc_ertr::now(); }); diff --git a/src/crimson/osd/shard_services.cc b/src/crimson/osd/shard_services.cc index 818006a2901..35d4f6d614a 100644 --- a/src/crimson/osd/shard_services.cc +++ b/src/crimson/osd/shard_services.cc @@ -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()); }); }); -- 2.47.3