Skip to content

Commit 3f1e887

Browse files
authored
Merge pull request ceph#51945 from rzarzynski/wip-bug-61504
crimson/osd: fix Notify life-time mismanagement in Watch::notify_ack Reviewed-by: Samuel Just <[email protected]> Reviewed-by: Matan Breizman <[email protected]>
2 parents eeae19f + 76bfae9 commit 3f1e887

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/crimson/osd/watch.cc

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,24 @@ seastar::future<> Watch::notify_ack(
122122
const uint64_t notify_id,
123123
const ceph::bufferlist& reply_bl)
124124
{
125-
logger().info("{}", __func__);
126-
return seastar::do_for_each(in_progress_notifies,
127-
[this_shared=shared_from_this(), reply_bl] (auto notify) {
128-
return notify->complete_watcher(this_shared, reply_bl);
129-
}
130-
).then([this] {
131-
in_progress_notifies.clear();
125+
logger().debug("{} gid={} cookie={} notify_id={}",
126+
__func__, get_watcher_gid(), get_cookie(), notify_id);
127+
const auto it = in_progress_notifies.find(notify_id);
128+
if (it == std::end(in_progress_notifies)) {
129+
logger().error("{} notify_id={} not found on the in-progess list."
130+
" Supressing but this should not happen.",
131+
__func__, notify_id);
132132
return seastar::now();
133-
});
133+
}
134+
auto notify = *it;
135+
logger().debug("Watch::notify_ack gid={} cookie={} found notify(id={})",
136+
get_watcher_gid(),
137+
get_cookie(),
138+
notify->get_id());
139+
// let's ensure we're extending the life-time till end of this method
140+
static_assert(std::is_same_v<decltype(notify), NotifyRef>);
141+
in_progress_notifies.erase(it);
142+
return notify->complete_watcher(shared_from_this(), reply_bl);
134143
}
135144

136145
seastar::future<> Watch::send_disconnect_msg()

0 commit comments

Comments
 (0)