]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/notifications: use topic references instead of pointers 50256/head
authorYuval Lifshitz <ylifshit@redhat.com>
Mon, 27 Feb 2023 13:18:51 +0000 (15:18 +0200)
committerYuval Lifshitz <ylifshit@redhat.com>
Mon, 27 Feb 2023 15:50:17 +0000 (17:50 +0200)
when passing topics to be populated by the functions

Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
src/rgw/driver/rados/rgw_notify.cc
src/rgw/rgw_admin.cc
src/rgw/rgw_pubsub.cc
src/rgw/rgw_pubsub.h
src/rgw/rgw_rest_pubsub.cc

index c20768a85efa8c3dca8edc6d39021bcb64b58c00..0821e69a9391127daacd1f2c2253fb4375d5396b 100644 (file)
@@ -780,7 +780,7 @@ static inline bool notification_match(reservation_t& res,
   const RGWPubSub ps(res.store, res.user_tenant);
   const RGWPubSub::Bucket ps_bucket(ps, res.bucket);
   rgw_pubsub_bucket_topics bucket_topics;
-  auto rc = ps_bucket.get_topics(res.dpp, &bucket_topics, res.yield);
+  auto rc = ps_bucket.get_topics(res.dpp, bucket_topics, res.yield);
   if (rc < 0) {
     // failed to fetch bucket topics
     return rc;
index f29e066e5b50f9524479e32191368c493e2e6408..d79ade2e650025441ec60d662fe6c71c2991e422 100644 (file)
@@ -10328,7 +10328,7 @@ next:
       }
 
       const RGWPubSub::Bucket b(ps, bucket.get());
-      ret = b.get_topics(dpp(), &result, null_yield);
+      ret = b.get_topics(dpp(), result, null_yield);
       if (ret < 0 && ret != -ENOENT) {
         cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
         return -ret;
@@ -10336,7 +10336,7 @@ next:
       encode_json("result", result, formatter.get());
     } else {
       rgw_pubsub_topics result;
-      int ret = ps.get_topics(dpp(), &result, null_yield);
+      int ret = ps.get_topics(dpp(), result, null_yield);
       if (ret < 0 && ret != -ENOENT) {
         cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
         return -ret;
@@ -10355,7 +10355,7 @@ next:
     RGWPubSub ps(driver, tenant);
 
     rgw_pubsub_topic topic;
-    ret = ps.get_topic(dpp(), topic_name, &topic, null_yield);
+    ret = ps.get_topic(dpp(), topic_name, topic, null_yield);
     if (ret < 0) {
       cerr << "ERROR: could not get topic: " << cpp_strerror(-ret) << std::endl;
       return -ret;
index 538b15e5a33c3ac9d36df01f0a6797d82061c539..6ebd87e3fe434ff574e5d2f989c31fcb554aa473 100644 (file)
@@ -407,10 +407,10 @@ RGWPubSub::RGWPubSub(rgw::sal::Driver* _driver, const std::string& _tenant)
   : driver(_driver), tenant(_tenant)
 {}
 
-int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, 
+int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topicsresult, 
     RGWObjVersionTracker *objv_tracker, optional_yield y) const
 {
-  const int ret = driver->read_topics(tenant, *result, objv_tracker, y, dpp);
+  const int ret = driver->read_topics(tenant, result, objv_tracker, y, dpp);
   if (ret < 0) {
     ldpp_dout(dpp, 10) << "WARNING: failed to read topics info: ret=" << ret << dendl;
     return ret;
@@ -429,10 +429,10 @@ int RGWPubSub::write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topi
   return 0;
 }
 
-int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result,
+int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topicsresult,
     RGWObjVersionTracker *objv_tracker, optional_yield y) const
 {
-  const int ret = bucket->read_topics(*result, objv_tracker, y, dpp);
+  const int ret = bucket->read_topics(result, objv_tracker, y, dpp);
   if (ret < 0 && ret != -ENOENT) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl;
     return ret;
@@ -453,10 +453,10 @@ int RGWPubSub::Bucket::write_topics(const DoutPrefixProvider *dpp, const rgw_pub
   return 0;
 }
 
-int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const
+int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topicresult, optional_yield y) const
 {
   rgw_pubsub_topics topics;
-  const int ret = read_topics(dpp, &topics, nullptr, y);
+  const int ret = read_topics(dpp, topics, nullptr, y);
   if (ret < 0) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl;
     return ret;
@@ -468,7 +468,7 @@ int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name,
     return -ENOENT;
   }
 
-  *result = iter->second;
+  result = iter->second;
   return 0;
 }
 
@@ -481,7 +481,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const
     const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name, optional_yield y) const {
   rgw_pubsub_topic topic_info;
 
-  int ret = ps.get_topic(dpp, topic_name, &topic_info, y);
+  int ret = ps.get_topic(dpp, topic_name, topic_info, y);
   if (ret < 0) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read topic '" << topic_name << "' info: ret=" << ret << dendl;
     return ret;
@@ -491,7 +491,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const
   RGWObjVersionTracker objv_tracker;
   rgw_pubsub_bucket_topics bucket_topics;
 
-  ret = read_topics(dpp, &bucket_topics, &objv_tracker, y);
+  ret = read_topics(dpp, bucket_topics, &objv_tracker, y);
   if (ret < 0) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read topics from bucket '" << 
       bucket->get_name() << "': ret=" << ret << dendl;
@@ -524,7 +524,7 @@ int RGWPubSub::Bucket::remove_notification(const DoutPrefixProvider *dpp, const
   RGWObjVersionTracker objv_tracker;
   rgw_pubsub_bucket_topics bucket_topics;
 
-  auto ret = read_topics(dpp, &bucket_topics, &objv_tracker, y);
+  auto ret = read_topics(dpp, bucket_topics, &objv_tracker, y);
   if (ret < 0) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl;
     return ret;
@@ -559,7 +559,7 @@ int RGWPubSub::Bucket::remove_notifications(const DoutPrefixProvider *dpp, optio
 {
   // get all topics on a bucket
   rgw_pubsub_bucket_topics bucket_topics;
-  auto ret  = get_topics(dpp, &bucket_topics, y);
+  auto ret  = get_topics(dpp, bucket_topics, y);
   if (ret < 0 && ret != -ENOENT) {
     ldpp_dout(dpp, 1) << "ERROR: failed to get list of topics from bucket '" << bucket->get_name() << "', ret=" << ret << dendl;
     return ret ;
@@ -593,7 +593,7 @@ int RGWPubSub::create_topic(const DoutPrefixProvider *dpp, const std::string& na
   RGWObjVersionTracker objv_tracker;
   rgw_pubsub_topics topics;
 
-  int ret = read_topics(dpp, &topics, &objv_tracker, y);
+  int ret = read_topics(dpp, topics, &objv_tracker, y);
   if (ret < 0 && ret != -ENOENT) {
     // its not an error if not topics exist, we create one
     ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl;
@@ -621,7 +621,7 @@ int RGWPubSub::remove_topic(const DoutPrefixProvider *dpp, const std::string& na
   RGWObjVersionTracker objv_tracker;
   rgw_pubsub_topics topics;
 
-  int ret = read_topics(dpp, &topics, &objv_tracker, y);
+  int ret = read_topics(dpp, topics, &objv_tracker, y);
   if (ret < 0 && ret != -ENOENT) {
     ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl;
     return ret;
index 18828281ce6bc3e9eac19fcea21d1dcef3f1317e..974581ce3d9175d124c4eea6f7d03ebcd233c7a1 100644 (file)
@@ -540,7 +540,7 @@ class RGWPubSub
   rgw::sal::Driver* const driver;
   const std::string tenant;
 
-  int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, 
+  int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topicsresult, 
       RGWObjVersionTracker* objv_tracker, optional_yield y) const;
   int write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topics& topics,
                        RGWObjVersionTracker* objv_tracker, optional_yield y) const;
@@ -556,7 +556,7 @@ public:
     // read the list of topics associated with a bucket and populate into result
     // use version tacker to enforce atomicity between read/write
     // return 0 on success or if no topic was associated with the bucket, error code otherwise
-    int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, 
+    int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topicsresult, 
         RGWObjVersionTracker* objv_tracker, optional_yield y) const;
     // set the list of topics associated with a bucket
     // use version tacker to enforce atomicity between read/write
@@ -570,7 +570,7 @@ public:
 
     // get the list of topics associated with a bucket and populate into result
     // return 0 on success or if no topic was associated with the bucket, error code otherwise
-    int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, optional_yield y) const {
+    int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topicsresult, optional_yield y) const {
       return read_topics(dpp, result, nullptr, y);
     }
     // adds a topic + filter (event list, and possibly name metadata or tags filters) to a bucket
@@ -595,13 +595,13 @@ public:
 
   // get the list of topics
   // return 0 on success or if no topic was associated with the bucket, error code otherwise
-  int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, optional_yield y) const {
+  int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topicsresult, optional_yield y) const {
     return read_topics(dpp, result, nullptr, y);
   }
   // get a topic with by its name and populate it into "result"
   // return -ENOENT if the topic does not exists 
   // return 0 on success, error code otherwise
-  int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const;
+  int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topicresult, optional_yield y) const;
   // create a topic with a name only
   // if the topic already exists it is a no-op (considered success)
   // return 0 on success, error code otherwise
index db361bce3bd30f8326699ffdce5da9e81ab50fcd..b68c3b5996675b7ccd52fb2c3184dad6bdbb7e09 100644 (file)
@@ -220,7 +220,7 @@ public:
 
 void RGWPSListTopicsOp::execute(optional_yield y) {
   const RGWPubSub ps(driver, s->owner.get_id().tenant);
-  op_ret = ps.get_topics(this, &result, y);
+  op_ret = ps.get_topics(this, result, y);
   // if there are no topics it is not considered an error
   op_ret = op_ret == -ENOENT ? 0 : op_ret;
   if (op_ret < 0) {
@@ -298,7 +298,7 @@ void RGWPSGetTopicOp::execute(optional_yield y) {
     return;
   }
   const RGWPubSub ps(driver, s->owner.get_id().tenant);
-  op_ret = ps.get_topic(this, topic_name, &result, y);
+  op_ret = ps.get_topic(this, topic_name, result, y);
   if (op_ret < 0) {
     ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
     return;
@@ -374,7 +374,7 @@ void RGWPSGetTopicAttributesOp::execute(optional_yield y) {
     return;
   }
   const RGWPubSub ps(driver, s->owner.get_id().tenant);
-  op_ret = ps.get_topic(this, topic_name, &result, y);
+  op_ret = ps.get_topic(this, topic_name, result, y);
   if (op_ret < 0) {
     ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
     return;
@@ -651,7 +651,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) {
   if(configurations.list.empty()) {
     // get all topics on a bucket
     rgw_pubsub_bucket_topics bucket_topics;
-    op_ret = b.get_topics(this, &bucket_topics, y);
+    op_ret = b.get_topics(this, bucket_topics, y);
     if (op_ret < 0) {
       ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
       return;
@@ -691,7 +691,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) {
 
     // get topic information. destination information is stored in the topic
     rgw_pubsub_topic topic_info;  
-    op_ret = ps.get_topic(this, topic_name, &topic_info, y);
+    op_ret = ps.get_topic(this, topic_name, topic_info, y);
     if (op_ret < 0) {
       ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
       return;
@@ -794,7 +794,7 @@ void RGWPSDeleteNotifOp::execute(optional_yield y) {
 
   // get all topics on a bucket
   rgw_pubsub_bucket_topics bucket_topics;
-  op_ret = b.get_topics(this, &bucket_topics, y);
+  op_ret = b.get_topics(this, bucket_topics, y);
   if (op_ret < 0) {
     ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
     return;
@@ -891,7 +891,7 @@ void RGWPSListNotifsOp::execute(optional_yield y) {
   
   // get all topics on a bucket
   rgw_pubsub_bucket_topics bucket_topics;
-  op_ret = b.get_topics(this, &bucket_topics, y);
+  op_ret = b.get_topics(this, bucket_topics, y);
   if (op_ret < 0) {
     ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
     return;