]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: fix Notify life-time mismanagement in Watch::notify_ack
authorRadosław Zarzyński <rzarzyns@redhat.com>
Tue, 6 Jun 2023 15:43:21 +0000 (17:43 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 9 Jun 2023 17:31:47 +0000 (17:31 +0000)
Fixes: https://tracker.ceph.com/issues/61504
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/osd/watch.cc

index f71d915bb9d7ab6b3e14352b7ba42a0f5430bca7..bc8da71c882aed769ab530b1e06e4f65d54148ef 100644 (file)
@@ -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<decltype(notify), NotifyRef>);
+  in_progress_notifies.erase(it);
+  return notify->complete_watcher(shared_from_this(), reply_bl);
 }
 
 seastar::future<> Watch::send_disconnect_msg()