From: Vedansh Bhartia Date: Wed, 7 Jun 2023 15:09:51 +0000 (+0530) Subject: rgw: pass boost intrusive_ptr to DataLogBackends flat_map X-Git-Tag: v19.0.0~1014^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6b0c045329ff42407f1cc0d5ee958a3d080604d3;p=ceph.git rgw: pass boost intrusive_ptr to DataLogBackends flat_map When emplacing a new backend, use an explicitly constructed intrusive_ptr so that it gets destroyed if the emplace fails. Though the destructor is already called, this behaviour cannot be relied upon. std::map does not exhibit the same behaviour, and would have leaked memory had it been used instead. Signed-off-by: Vedansh Bhartia --- diff --git a/src/rgw/driver/rados/rgw_datalog.cc b/src/rgw/driver/rados/rgw_datalog.cc index 5bacea7018b5f..167cbcdba4a89 100644 --- a/src/rgw/driver/rados/rgw_datalog.cc +++ b/src/rgw/driver/rados/rgw_datalog.cc @@ -440,10 +440,14 @@ bs::error_code DataLogBackends::handle_init(entries_t e) noexcept { try { switch (gen.type) { case log_type::omap: - emplace(gen_id, new RGWDataChangesOmap(ioctx, datalog, gen_id, shards)); + emplace(gen_id, + boost::intrusive_ptr(new RGWDataChangesOmap(ioctx, datalog, gen_id, shards)) + ); break; case log_type::fifo: - emplace(gen_id, new RGWDataChangesFIFO(ioctx, datalog, gen_id, shards)); + emplace(gen_id, + boost::intrusive_ptr(new RGWDataChangesFIFO(ioctx, datalog, gen_id, shards)) + ); break; default: lderr(datalog.cct)