From 2995271c8f51b212773dd5f4afd0d2e391461902 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rados=C5=82aw=20Zarzy=C5=84ski?= Date: Tue, 6 Jun 2023 17:43:21 +0200 Subject: [PATCH] crimson/osd: fix Notify life-time mismanagement in Watch::notify_ack Fixes: https://tracker.ceph.com/issues/61504 Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 83d1634e192d864630ce927f89c61d8d626923e5) --- src/crimson/osd/watch.cc | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index f71d915bb9d7..bc8da71c882a 100644 --- a/src/crimson/osd/watch.cc +++ b/src/crimson/osd/watch.cc @@ -122,15 +122,19 @@ seastar::future<> Watch::notify_ack( const uint64_t notify_id, const ceph::bufferlist& reply_bl) { - logger().info("{}", __func__); - return seastar::do_for_each(in_progress_notifies, - [this_shared=shared_from_this(), reply_bl] (auto notify) { - return notify->complete_watcher(this_shared, reply_bl); - } - ).then([this] { - in_progress_notifies.clear(); - return seastar::now(); - }); + logger().debug("{} gid={} cookie={} notify_id={}", + __func__, get_watcher_gid(), get_cookie(), notify_id); + const auto it = in_progress_notifies.find(notify_id); + assert(it != std::end(in_progress_notifies)); + auto notify = *it; + logger().debug("Watch::notify_ack gid={} cookie={} found notify(id={})", + get_watcher_gid(), + get_cookie(), + notify->get_id()); + // let's ensure we're extending the life-time till end of this method + static_assert(std::is_same_v); + in_progress_notifies.erase(it); + return notify->complete_watcher(shared_from_this(), reply_bl); } seastar::future<> Watch::send_disconnect_msg() -- 2.47.3