From 18ce15ab5ecce0352dde1fac2d62facf37180431 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 20 Feb 2020 16:09:19 +0800 Subject: [PATCH] crimson/osd: capture watcher when calling its member function otherwise the extracted node handler will be destroyed, and so does the watcher enclosed in it. Signed-off-by: Kefu Chai --- src/crimson/osd/ops_executer.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/crimson/osd/ops_executer.cc b/src/crimson/osd/ops_executer.cc index c3d797e5815..46c9ce3ee6d 100644 --- a/src/crimson/osd/ops_executer.cc +++ b/src/crimson/osd/ops_executer.cc @@ -210,11 +210,13 @@ OpsExecuter::watch_errorator::future<> OpsExecuter::do_op_watch_subop_unwatch( }, [] (auto&& ctx, ObjectContextRef obc) { if (auto nh = obc->watchers.extract(ctx.key); !nh.empty()) { - logger().info("op_effect: disconnect watcher {}", ctx.key); - return nh.mapped()->remove(ctx.send_disconnect); + return seastar::do_with(std::move(nh.mapped()), + [ctx](auto&& watcher) { + logger().info("op_effect: disconnect watcher {}", ctx.key); + return watcher->remove(ctx.send_disconnect); + }); } else { - logger().info("op_effect: disconnect failed to find watcher {}", - ctx.key); + logger().info("op_effect: disconnect failed to find watcher {}", ctx.key); return seastar::now(); } }); -- 2.39.5