]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
neorados: `RAODS::notify` returns reply map and missed set
authorAdam Emerson <aemerson@redhat.com>
Fri, 15 Sep 2023 21:46:41 +0000 (17:46 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Apr 2025 15:10:13 +0000 (11:10 -0400)
So the format doesn't spill out of the API boundary.

Signed-off-by: Adam Emerson <aemerson@redhat.com>
src/include/neorados/RADOS.hpp
src/neorados/RADOS.cc
src/test/neorados/watch_notify.cc

index 639a0bce57a78a9acbd1579a8e5901e4ed742e88..ab10e61858101c98ab2076db15bb6122345e87c4 100644 (file)
@@ -1705,7 +1705,12 @@ public:
   tl::expected<ceph::timespan, boost::system::error_code>
   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<std::pair<std::uint64_t, std::uint64_t>,
+                                      ceph::buffer::list> reply_map,
+          boost::container::flat_set<std::pair<std::uint64_t, std::uint64_t>>
+              missed_set);
   using NotifyComp = boost::asio::any_completion_handler<NotifySig>;
   template<boost::asio::completion_token_for<NotifySig> CompletionToken>
   auto notify(Object o, IOContext ioc, ceph::buffer::list bl,
index 1f7e89db8829bb4f02dee9535ebd6a3480246500..c7eae5e93c30bff86cc41b60abcddb49dfbb0784 100644 (file)
@@ -1674,7 +1674,13 @@ struct NotifyHandler : std::enable_shared_from_this<NotifyHandler> {
     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<std::pair<uint64_t, uint64_t>, buffer::list> reply_map;
+      bc::flat_set<std::pair<uint64_t, uint64_t>> 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)));
     }
   }
 };
index 25efab9058b3c8a5cebaf2053934362c4fa0a878..e3853f2450cf92fca64be7aa55e5eae51e64af32 100644 (file)
@@ -125,13 +125,9 @@ CORO_TEST_F(NeoRadosWatchNotify, WatchNotify, NeoRadosWatchNotifyTest) {
   std::vector<neorados::ObjWatcher> 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<std::pair<uint64_t, uint64_t>, buffer::list> reply_map;
-  std::set<std::pair<uint64_t, uint64_t>> 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<void> {
-    auto reply = co_await r.notify(oid, ioc, {}, {}, asio::use_awaitable);
-    std::map<std::pair<uint64_t, uint64_t>, buffer::list> reply_map;
-    std::set<std::pair<uint64_t, uint64_t>> 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));