summaryrefslogtreecommitdiffstats
path: root/src/rgw/driver
diff options
context:
space:
mode:
authorYuval Lifshitz <ylifshit@ibm.com>2024-08-27 22:05:21 +0200
committerYuval Lifshitz <ylifshit@ibm.com>2024-09-05 16:36:28 +0200
commit2e319cb30c84d0b653fdae5eedbd99ff31f72fe7 (patch)
tree8da3bc6170fa0dbe187d73d15975a99cbb5766d4 /src/rgw/driver
parentMerge pull request #59386 from mkogan1/wip-qlen_qactive (diff)
downloadceph-2e319cb30c84d0b653fdae5eedbd99ff31f72fe7.tar.xz
ceph-2e319cb30c84d0b653fdae5eedbd99ff31f72fe7.zip
rgw/notifications: free completion pointer using unique_ptr
also fix access to possible dpp dangling pointer Fixes: https://tracker.ceph.com/issues/67658 Signed-off-by: Yuval Lifshitz <ylifshit@ibm.com>
Diffstat (limited to 'src/rgw/driver')
-rw-r--r--src/rgw/driver/rados/rgw_notify.cc35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/rgw/driver/rados/rgw_notify.cc b/src/rgw/driver/rados/rgw_notify.cc
index 6b1dd9651f0..6fdc4b91677 100644
--- a/src/rgw/driver/rados/rgw_notify.cc
+++ b/src/rgw/driver/rados/rgw_notify.cc
@@ -60,22 +60,19 @@ auto make_stack_allocator() {
const std::string Q_LIST_OBJECT_NAME = "queues_list_object";
struct PublishCommitCompleteArg {
+ PublishCommitCompleteArg(const std::string& _queue_name, CephContext* _cct)
+ : queue_name{_queue_name}, cct{_cct} {}
- PublishCommitCompleteArg(std::string _queue_name, const DoutPrefixProvider *_dpp)
- : queue_name{std::move(_queue_name)}, dpp{_dpp} {}
-
- std::string queue_name;
- const DoutPrefixProvider *dpp;
+ const std::string queue_name;
+ CephContext* const cct;
};
-void publish_commit_completion(rados_completion_t completion, void *arg) {
- auto *comp_obj = reinterpret_cast<librados::AioCompletionImpl *>(completion);
- std::unique_ptr<PublishCommitCompleteArg> pcc_arg(reinterpret_cast<PublishCommitCompleteArg *>(arg));
- if (comp_obj->get_return_value() < 0) {
- ldpp_dout(pcc_arg->dpp, 1) << "ERROR: failed to commit reservation to queue: "
- << pcc_arg->queue_name << ". error: " << comp_obj->get_return_value()
- << dendl;
- }
+void publish_commit_completion(rados_completion_t completion, void* arg) {
+ std::unique_ptr<PublishCommitCompleteArg> pcc_args{reinterpret_cast<PublishCommitCompleteArg*>(arg)};
+ if (const auto rc = rados_aio_get_return_value(completion); rc < 0) {
+ ldout(pcc_args->cct, 1) << "ERROR: failed to commit reservation to queue: "
+ << pcc_args->queue_name << ". error: " << rc << dendl;
+ }
};
class Manager : public DoutPrefixProvider {
@@ -1243,19 +1240,17 @@ int publish_commit(rgw::sal::Object* obj,
std::vector<buffer::list> bl_data_vec{std::move(bl)};
librados::ObjectWriteOperation op;
cls_2pc_queue_commit(op, bl_data_vec, topic.res_id);
- aio_completion_ptr completion {librados::Rados::aio_create_completion()};
- auto pcc_arg = make_unique<PublishCommitCompleteArg>(queue_name, dpp);
- completion->set_complete_callback(pcc_arg.get(), publish_commit_completion);
- auto &io_ctx = res.store->getRados()->get_notif_pool_ctx();
- int ret = io_ctx.aio_operate(queue_name, completion.get(), &op);
topic.res_id = cls_2pc_reservation::NO_ID;
- if (ret < 0) {
+ auto pcc_arg = make_unique<PublishCommitCompleteArg>(queue_name, dpp->get_cct());
+ aio_completion_ptr completion{librados::Rados::aio_create_completion(pcc_arg.get(), publish_commit_completion)};
+ auto& io_ctx = res.store->getRados()->get_notif_pool_ctx();
+ if (const int ret = io_ctx.aio_operate(queue_name, completion.get(), &op); ret < 0) {
ldpp_dout(dpp, 1) << "ERROR: failed to commit reservation to queue: "
<< queue_name << ". error: " << ret << dendl;
return ret;
}
+ // args will be released inside the callback
pcc_arg.release();
- completion.release();
} else {
try {
// TODO add endpoint LRU cache