From: Radosław Zarzyński Date: Tue, 6 Jun 2023 15:43:21 +0000 (+0200) Subject: crimson/osd: fix Notify life-time mismanagement in Watch::notify_ack X-Git-Tag: v18.2.1~176^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2995271c8f51b212773dd5f4afd0d2e391461902;p=ceph-ci.git 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) --- diff --git a/src/crimson/osd/watch.cc b/src/crimson/osd/watch.cc index f71d915bb9d..bc8da71c882 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()