When emplacing objects into the trim notify handler of
BucketTrimWatcher, use a unique_ptr for the handler so that it is
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.
Fixes: https://tracker.ceph.com/issues/57938
Signed-off-by: Vedansh Bhartia <vedanshbhartia@gmail.com>
(cherry picked from commit
43ef4753eb338781529a7dc8360eab13d56fce85)
BucketTrimWatcher(rgw::sal::RGWRadosStore *store, const rgw_raw_obj& obj,
TrimCounters::Server *counters)
: store(store), obj(obj) {
- handlers.emplace(NotifyTrimCounters, new TrimCounters::Handler(counters));
- handlers.emplace(NotifyTrimComplete, new TrimComplete::Handler(counters));
+ handlers.emplace(NotifyTrimCounters,
+ std::make_unique<TrimCounters::Handler>(counters));
+ handlers.emplace(NotifyTrimComplete,
+ std::make_unique<TrimComplete::Handler>(counters));
}
~BucketTrimWatcher() {