Skip to content

Commit 3f7a295

Browse files
committed
rgw/notifications: use topic references instead of pointers
when passing topics to be populated by the functions Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
1 parent a3b050e commit 3f7a295

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

src/rgw/driver/rados/rgw_notify.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ static inline bool notification_match(reservation_t& res,
780780
const RGWPubSub ps(res.store, res.user_tenant);
781781
const RGWPubSub::Bucket ps_bucket(ps, res.bucket);
782782
rgw_pubsub_bucket_topics bucket_topics;
783-
auto rc = ps_bucket.get_topics(res.dpp, &bucket_topics, res.yield);
783+
auto rc = ps_bucket.get_topics(res.dpp, bucket_topics, res.yield);
784784
if (rc < 0) {
785785
// failed to fetch bucket topics
786786
return rc;

src/rgw/rgw_admin.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10328,15 +10328,15 @@ int main(int argc, const char **argv)
1032810328
}
1032910329

1033010330
const RGWPubSub::Bucket b(ps, bucket.get());
10331-
ret = b.get_topics(dpp(), &result, null_yield);
10331+
ret = b.get_topics(dpp(), result, null_yield);
1033210332
if (ret < 0 && ret != -ENOENT) {
1033310333
cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
1033410334
return -ret;
1033510335
}
1033610336
encode_json("result", result, formatter.get());
1033710337
} else {
1033810338
rgw_pubsub_topics result;
10339-
int ret = ps.get_topics(dpp(), &result, null_yield);
10339+
int ret = ps.get_topics(dpp(), result, null_yield);
1034010340
if (ret < 0 && ret != -ENOENT) {
1034110341
cerr << "ERROR: could not get topics: " << cpp_strerror(-ret) << std::endl;
1034210342
return -ret;
@@ -10355,7 +10355,7 @@ int main(int argc, const char **argv)
1035510355
RGWPubSub ps(driver, tenant);
1035610356

1035710357
rgw_pubsub_topic topic;
10358-
ret = ps.get_topic(dpp(), topic_name, &topic, null_yield);
10358+
ret = ps.get_topic(dpp(), topic_name, topic, null_yield);
1035910359
if (ret < 0) {
1036010360
cerr << "ERROR: could not get topic: " << cpp_strerror(-ret) << std::endl;
1036110361
return -ret;

src/rgw/rgw_pubsub.cc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,10 @@ RGWPubSub::RGWPubSub(rgw::sal::Driver* _driver, const std::string& _tenant)
407407
: driver(_driver), tenant(_tenant)
408408
{}
409409

410-
int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result,
410+
int RGWPubSub::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result,
411411
RGWObjVersionTracker *objv_tracker, optional_yield y) const
412412
{
413-
const int ret = driver->read_topics(tenant, *result, objv_tracker, y, dpp);
413+
const int ret = driver->read_topics(tenant, result, objv_tracker, y, dpp);
414414
if (ret < 0) {
415415
ldpp_dout(dpp, 10) << "WARNING: failed to read topics info: ret=" << ret << dendl;
416416
return ret;
@@ -429,10 +429,10 @@ int RGWPubSub::write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topi
429429
return 0;
430430
}
431431

432-
int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result,
432+
int RGWPubSub::Bucket::read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result,
433433
RGWObjVersionTracker *objv_tracker, optional_yield y) const
434434
{
435-
const int ret = bucket->read_topics(*result, objv_tracker, y, dpp);
435+
const int ret = bucket->read_topics(result, objv_tracker, y, dpp);
436436
if (ret < 0 && ret != -ENOENT) {
437437
ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl;
438438
return ret;
@@ -453,10 +453,10 @@ int RGWPubSub::Bucket::write_topics(const DoutPrefixProvider *dpp, const rgw_pub
453453
return 0;
454454
}
455455

456-
int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const
456+
int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic& result, optional_yield y) const
457457
{
458458
rgw_pubsub_topics topics;
459-
const int ret = read_topics(dpp, &topics, nullptr, y);
459+
const int ret = read_topics(dpp, topics, nullptr, y);
460460
if (ret < 0) {
461461
ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl;
462462
return ret;
@@ -468,7 +468,7 @@ int RGWPubSub::get_topic(const DoutPrefixProvider *dpp, const std::string& name,
468468
return -ENOENT;
469469
}
470470

471-
*result = iter->second;
471+
result = iter->second;
472472
return 0;
473473
}
474474

@@ -481,7 +481,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const
481481
const rgw::notify::EventTypeList& events, OptionalFilter s3_filter, const std::string& notif_name, optional_yield y) const {
482482
rgw_pubsub_topic topic_info;
483483

484-
int ret = ps.get_topic(dpp, topic_name, &topic_info, y);
484+
int ret = ps.get_topic(dpp, topic_name, topic_info, y);
485485
if (ret < 0) {
486486
ldpp_dout(dpp, 1) << "ERROR: failed to read topic '" << topic_name << "' info: ret=" << ret << dendl;
487487
return ret;
@@ -491,7 +491,7 @@ int RGWPubSub::Bucket::create_notification(const DoutPrefixProvider *dpp, const
491491
RGWObjVersionTracker objv_tracker;
492492
rgw_pubsub_bucket_topics bucket_topics;
493493

494-
ret = read_topics(dpp, &bucket_topics, &objv_tracker, y);
494+
ret = read_topics(dpp, bucket_topics, &objv_tracker, y);
495495
if (ret < 0) {
496496
ldpp_dout(dpp, 1) << "ERROR: failed to read topics from bucket '" <<
497497
bucket->get_name() << "': ret=" << ret << dendl;
@@ -524,7 +524,7 @@ int RGWPubSub::Bucket::remove_notification(const DoutPrefixProvider *dpp, const
524524
RGWObjVersionTracker objv_tracker;
525525
rgw_pubsub_bucket_topics bucket_topics;
526526

527-
auto ret = read_topics(dpp, &bucket_topics, &objv_tracker, y);
527+
auto ret = read_topics(dpp, bucket_topics, &objv_tracker, y);
528528
if (ret < 0) {
529529
ldpp_dout(dpp, 1) << "ERROR: failed to read bucket topics info: ret=" << ret << dendl;
530530
return ret;
@@ -559,7 +559,7 @@ int RGWPubSub::Bucket::remove_notifications(const DoutPrefixProvider *dpp, optio
559559
{
560560
// get all topics on a bucket
561561
rgw_pubsub_bucket_topics bucket_topics;
562-
auto ret = get_topics(dpp, &bucket_topics, y);
562+
auto ret = get_topics(dpp, bucket_topics, y);
563563
if (ret < 0 && ret != -ENOENT) {
564564
ldpp_dout(dpp, 1) << "ERROR: failed to get list of topics from bucket '" << bucket->get_name() << "', ret=" << ret << dendl;
565565
return ret ;
@@ -593,7 +593,7 @@ int RGWPubSub::create_topic(const DoutPrefixProvider *dpp, const std::string& na
593593
RGWObjVersionTracker objv_tracker;
594594
rgw_pubsub_topics topics;
595595

596-
int ret = read_topics(dpp, &topics, &objv_tracker, y);
596+
int ret = read_topics(dpp, topics, &objv_tracker, y);
597597
if (ret < 0 && ret != -ENOENT) {
598598
// its not an error if not topics exist, we create one
599599
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
621621
RGWObjVersionTracker objv_tracker;
622622
rgw_pubsub_topics topics;
623623

624-
int ret = read_topics(dpp, &topics, &objv_tracker, y);
624+
int ret = read_topics(dpp, topics, &objv_tracker, y);
625625
if (ret < 0 && ret != -ENOENT) {
626626
ldpp_dout(dpp, 1) << "ERROR: failed to read topics info: ret=" << ret << dendl;
627627
return ret;

src/rgw/rgw_pubsub.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class RGWPubSub
540540
rgw::sal::Driver* const driver;
541541
const std::string tenant;
542542

543-
int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result,
543+
int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result,
544544
RGWObjVersionTracker* objv_tracker, optional_yield y) const;
545545
int write_topics(const DoutPrefixProvider *dpp, const rgw_pubsub_topics& topics,
546546
RGWObjVersionTracker* objv_tracker, optional_yield y) const;
@@ -556,7 +556,7 @@ class RGWPubSub
556556
// read the list of topics associated with a bucket and populate into result
557557
// use version tacker to enforce atomicity between read/write
558558
// return 0 on success or if no topic was associated with the bucket, error code otherwise
559-
int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result,
559+
int read_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result,
560560
RGWObjVersionTracker* objv_tracker, optional_yield y) const;
561561
// set the list of topics associated with a bucket
562562
// use version tacker to enforce atomicity between read/write
@@ -570,7 +570,7 @@ class RGWPubSub
570570

571571
// get the list of topics associated with a bucket and populate into result
572572
// return 0 on success or if no topic was associated with the bucket, error code otherwise
573-
int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics *result, optional_yield y) const {
573+
int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_bucket_topics& result, optional_yield y) const {
574574
return read_topics(dpp, result, nullptr, y);
575575
}
576576
// adds a topic + filter (event list, and possibly name metadata or tags filters) to a bucket
@@ -595,13 +595,13 @@ class RGWPubSub
595595

596596
// get the list of topics
597597
// return 0 on success or if no topic was associated with the bucket, error code otherwise
598-
int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics *result, optional_yield y) const {
598+
int get_topics(const DoutPrefixProvider *dpp, rgw_pubsub_topics& result, optional_yield y) const {
599599
return read_topics(dpp, result, nullptr, y);
600600
}
601601
// get a topic with by its name and populate it into "result"
602602
// return -ENOENT if the topic does not exists
603603
// return 0 on success, error code otherwise
604-
int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic *result, optional_yield y) const;
604+
int get_topic(const DoutPrefixProvider *dpp, const std::string& name, rgw_pubsub_topic& result, optional_yield y) const;
605605
// create a topic with a name only
606606
// if the topic already exists it is a no-op (considered success)
607607
// return 0 on success, error code otherwise

src/rgw/rgw_rest_pubsub.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class RGWPSListTopicsOp : public RGWOp {
220220

221221
void RGWPSListTopicsOp::execute(optional_yield y) {
222222
const RGWPubSub ps(driver, s->owner.get_id().tenant);
223-
op_ret = ps.get_topics(this, &result, y);
223+
op_ret = ps.get_topics(this, result, y);
224224
// if there are no topics it is not considered an error
225225
op_ret = op_ret == -ENOENT ? 0 : op_ret;
226226
if (op_ret < 0) {
@@ -298,7 +298,7 @@ void RGWPSGetTopicOp::execute(optional_yield y) {
298298
return;
299299
}
300300
const RGWPubSub ps(driver, s->owner.get_id().tenant);
301-
op_ret = ps.get_topic(this, topic_name, &result, y);
301+
op_ret = ps.get_topic(this, topic_name, result, y);
302302
if (op_ret < 0) {
303303
ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
304304
return;
@@ -374,7 +374,7 @@ void RGWPSGetTopicAttributesOp::execute(optional_yield y) {
374374
return;
375375
}
376376
const RGWPubSub ps(driver, s->owner.get_id().tenant);
377-
op_ret = ps.get_topic(this, topic_name, &result, y);
377+
op_ret = ps.get_topic(this, topic_name, result, y);
378378
if (op_ret < 0) {
379379
ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
380380
return;
@@ -651,7 +651,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) {
651651
if(configurations.list.empty()) {
652652
// get all topics on a bucket
653653
rgw_pubsub_bucket_topics bucket_topics;
654-
op_ret = b.get_topics(this, &bucket_topics, y);
654+
op_ret = b.get_topics(this, bucket_topics, y);
655655
if (op_ret < 0) {
656656
ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
657657
return;
@@ -691,7 +691,7 @@ void RGWPSCreateNotifOp::execute(optional_yield y) {
691691

692692
// get topic information. destination information is stored in the topic
693693
rgw_pubsub_topic topic_info;
694-
op_ret = ps.get_topic(this, topic_name, &topic_info, y);
694+
op_ret = ps.get_topic(this, topic_name, topic_info, y);
695695
if (op_ret < 0) {
696696
ldpp_dout(this, 1) << "failed to get topic '" << topic_name << "', ret=" << op_ret << dendl;
697697
return;
@@ -794,7 +794,7 @@ void RGWPSDeleteNotifOp::execute(optional_yield y) {
794794

795795
// get all topics on a bucket
796796
rgw_pubsub_bucket_topics bucket_topics;
797-
op_ret = b.get_topics(this, &bucket_topics, y);
797+
op_ret = b.get_topics(this, bucket_topics, y);
798798
if (op_ret < 0) {
799799
ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
800800
return;
@@ -891,7 +891,7 @@ void RGWPSListNotifsOp::execute(optional_yield y) {
891891

892892
// get all topics on a bucket
893893
rgw_pubsub_bucket_topics bucket_topics;
894-
op_ret = b.get_topics(this, &bucket_topics, y);
894+
op_ret = b.get_topics(this, bucket_topics, y);
895895
if (op_ret < 0) {
896896
ldpp_dout(this, 1) << "failed to get list of topics from bucket '" << bucket_name << "', ret=" << op_ret << dendl;
897897
return;

0 commit comments

Comments
 (0)