From bc02229a054a19c1d5431bf43518cfe184435b2f Mon Sep 17 00:00:00 2001 From: Adam Emerson Date: Fri, 15 Sep 2023 17:46:41 -0400 Subject: [PATCH] neorados: `RAODS::notify` returns reply map and missed set So the format doesn't spill out of the API boundary. Signed-off-by: Adam Emerson --- src/include/neorados/RADOS.hpp | 7 ++++++- src/neorados/RADOS.cc | 8 +++++++- src/test/neorados/watch_notify.cc | 19 ++++++------------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/include/neorados/RADOS.hpp b/src/include/neorados/RADOS.hpp index 639a0bce57a..ab10e618581 100644 --- a/src/include/neorados/RADOS.hpp +++ b/src/include/neorados/RADOS.hpp @@ -1705,7 +1705,12 @@ public: tl::expected check_watch(uint64_t cookie); - using NotifySig = void(boost::system::error_code, ceph::buffer::list); + using NotifySig = + void(boost::system::error_code, + boost::container::flat_map, + ceph::buffer::list> reply_map, + boost::container::flat_set> + missed_set); using NotifyComp = boost::asio::any_completion_handler; template CompletionToken> auto notify(Object o, IOContext ioc, ceph::buffer::list bl, diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc index 1f7e89db882..c7eae5e93c3 100644 --- a/src/neorados/RADOS.cc +++ b/src/neorados/RADOS.cc @@ -1674,7 +1674,13 @@ struct NotifyHandler : std::enable_shared_from_this { if ((acked && finished) || res) { objecter->linger_cancel(op); ceph_assert(c); - asio::dispatch(asio::append(std::move(c), res, std::move(rbl))); + bc::flat_map, buffer::list> reply_map; + bc::flat_set> missed_set; + auto p = rbl.cbegin(); + decode(reply_map, p); + decode(missed_set, p); + asio::dispatch(asio::append(std::move(c), res, std::move(reply_map), + std::move(missed_set))); } } }; diff --git a/src/test/neorados/watch_notify.cc b/src/test/neorados/watch_notify.cc index 25efab9058b..e3853f2450c 100644 --- a/src/test/neorados/watch_notify.cc +++ b/src/test/neorados/watch_notify.cc @@ -125,13 +125,9 @@ CORO_TEST_F(NeoRadosWatchNotify, WatchNotify, NeoRadosWatchNotifyTest) { std::vector watchers; co_await execute(notify_oid, ReadOp{}.list_watchers(&watchers)); EXPECT_EQ(1u, watchers.size()); - auto reply = co_await rados().notify(notify_oid, pool(), {}, {}, - asio::use_awaitable); - std::map, buffer::list> reply_map; - std::set> missed_set; - auto p = reply.cbegin(); - decode(reply_map, p); - decode(missed_set, p); + auto [reply_map, missed_set] + = co_await rados().notify(notify_oid, pool(), {}, {}, + asio::use_awaitable); EXPECT_EQ(1u, notify_cookies.size()); EXPECT_EQ(1u, notify_cookies.count(handle)); EXPECT_EQ(1u, reply_map.size()); @@ -186,12 +182,9 @@ CORO_TEST_F(NeoRadosWatchNotifyPoll, WatchNotify, NeoRadosTest) { EXPECT_EQ(1u, watchers.size()); auto notify = [](neorados::RADOS& r, neorados::IOContext ioc) -> asio::awaitable { - auto reply = co_await r.notify(oid, ioc, {}, {}, asio::use_awaitable); - std::map, buffer::list> reply_map; - std::set> missed_set; - auto p = reply.cbegin(); - decode(reply_map, p); - decode(missed_set, p); + auto [reply_map, missed_set] + = co_await r.notify(oid, ioc, {}, {}, asio::use_awaitable); + EXPECT_EQ(1u, reply_map.size()); EXPECT_EQ(5u, reply_map.begin()->second.length()); EXPECT_EQ(0, strncmp("reply", reply_map.begin()->second.c_str(), 5)); -- 2.39.5