From 17fc145f90c048bec4ddae35c7aa559cdd77115e Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 28 Feb 2021 13:23:29 +0800 Subject: [PATCH] crimson/osd: keep ClientRequest alive during `seastar::repeat()` before this change, `this` is wrapped by a smart pointer which is in turn captured by multiple continuations. the continuation with the longest life cycle is the one passed to `seastar::repeat()`. where the underlying `repeater` captures the continuation as its member variable. and `repeater` is not destroyed before `seastar::repeat()` returns. so, we only need to capture `opref` in the continuation passed to `seastar::repeat()`. Signed-off-by: Kefu Chai --- src/crimson/osd/osd_operations/client_request.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/crimson/osd/osd_operations/client_request.cc b/src/crimson/osd/osd_operations/client_request.cc index 1f59a907080..7b7493e4f1c 100644 --- a/src/crimson/osd/osd_operations/client_request.cc +++ b/src/crimson/osd/osd_operations/client_request.cc @@ -65,24 +65,23 @@ seastar::future<> ClientRequest::start() { logger().debug("{}: start", *this); - IRef opref = this; return crimson::common::handle_system_shutdown( - [this, opref=std::move(opref)]() mutable { - return seastar::repeat([this, opref]() mutable { + [this, opref=IRef{this}]() mutable { + return seastar::repeat([this, opref=std::move(opref)]() mutable { logger().debug("{}: in repeat", *this); return with_blocking_future(handle.enter(cp().await_map)) - .then([this]() { + .then([this] { return with_blocking_future(osd.osdmap_gate.wait_for_map(m->get_min_epoch())); }).then([this](epoch_t epoch) { return with_blocking_future(handle.enter(cp().get_pg)); }).then([this] { return with_blocking_future(osd.wait_for_pg(m->get_spg())); - }).then([this, opref](Ref pgref) mutable { + }).then([this](Ref pgref) mutable { epoch_t same_interval_since = pgref->get_interval_start_epoch(); logger().debug("{} same_interval_since: {}", *this, same_interval_since); return sequencer.start_op( - handle, prev_op_id, opref->get_id(), - [this, opref, pgref] { + handle, prev_op_id, get_id(), + [this, pgref] { PG &pg = *pgref; if (pg.can_discard_op(*m)) { logger().debug("{} op discarded, {}, same_primary_since: {}", -- 2.39.5