Serializer needs to use a unique_ptr like the rest of the SAL API.
Signed-off-by: Daniel Gryniewicz <dang@redhat.com>
{
utime_t lock_duration(cct->_conf->rgw_lc_lock_max_time, 0);
- rgw::sal::LCSerializer* lock = sal_lc->get_serializer(lc_index_lock_name,
- obj_names[index],
- cookie);
+ std::unique_ptr<rgw::sal::LCSerializer> lock =
+ sal_lc->get_serializer(lc_index_lock_name, obj_names[index], cookie);
ldpp_dout(this, 5) << "RGWLC::bucket_lc_post(): POST " << entry
<< " index: " << index << " worker ix: " << worker->ix
}
clean:
lock->unlock();
- delete lock;
ldpp_dout(this, 20) << "RGWLC::bucket_lc_post() unlock "
<< obj_names[index] << dendl;
return 0;
<< dendl;
int ret = 0;
- std::unique_ptr<rgw::sal::LCSerializer> serializer(
+ std::unique_ptr<rgw::sal::LCSerializer> serializer =
sal_lc->get_serializer(lc_index_lock_name, obj_names[index],
- std::string()));
+ std::string());
std::unique_ptr<rgw::sal::Lifecycle::LCEntry> entry;
if (max_lock_secs <= 0) {
<< "index: " << index << " worker ix: " << worker->ix
<< dendl;
- rgw::sal::LCSerializer* lock =
+ std::unique_ptr<rgw::sal::LCSerializer> lock =
sal_lc->get_serializer(lc_index_lock_name, lc_shard, std::string());
utime_t lock_for_s(max_lock_secs, 0);
ldpp_dout(this, 0) << "RGWLC::process(): failed to aquire lock on "
<< lc_shard << " after " << shard_lock.get_retries()
<< dendl;
- goto notlocked;
+ return 0;
}
do {
ldpp_dout(this, 0) << "RGWLC::process(): failed to aquire lock on "
<< lc_shard << " after " << shard_lock.get_retries()
<< dendl;
- goto notlocked;
+ return 0;
}
if (ret == -ENOENT) {
exit:
lock->unlock();
-notlocked:
- delete lock;
return 0;
}
entry->set_status(lc_uninitial);
int max_lock_secs = cct->_conf->rgw_lc_lock_max_time;
- rgw::sal::LCSerializer* lock = sal_lc->get_serializer(lc_index_lock_name,
- oid,
- cookie);
+ std::unique_ptr<rgw::sal::LCSerializer> lock =
+ sal_lc->get_serializer(lc_index_lock_name, oid, cookie);
utime_t time(max_lock_secs, 0);
int ret;
break;
} while(true);
lock->unlock();
- delete lock;
return ret;
}
void RGWCompleteMultipart::complete()
{
/* release exclusive lock iff not already */
- if (unlikely(serializer && serializer->is_locked())) {
+ if (unlikely(serializer.get() && serializer->is_locked())) {
int r = serializer->unlock();
if (r < 0) {
- ldpp_dout(this, 0) << "WARNING: failed to unlock " << serializer << dendl;
+ ldpp_dout(this, 0) << "WARNING: failed to unlock " << *serializer.get() << dendl;
}
}
send_response();
std::string etag;
std::string version_id;
bufferlist data;
- rgw::sal::MPSerializer* serializer;
+ std::unique_ptr<rgw::sal::MPSerializer> serializer;
jspan multipart_trace;
public:
- RGWCompleteMultipart() : serializer(nullptr) {}
- ~RGWCompleteMultipart() override { delete serializer; }
+ RGWCompleteMultipart() {}
+ ~RGWCompleteMultipart() = default;
int verify_permission(optional_yield y) override;
void pre_exec() override;
/** Create a randomized instance ID for this object */
virtual void gen_rand_obj_instance_name() = 0;
/** Get a multipart serializer for this object */
- virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) = 0;
+ virtual std::unique_ptr<MPSerializer> get_serializer(const DoutPrefixProvider *dpp,
+ const std::string& lock_name) = 0;
/** Move the data of an object to new placement storage */
virtual int transition(Bucket* bucket,
const rgw_placement_rule& placement_rule,
virtual int put_head(const std::string& oid, LCHead& head) = 0;
/** Get a serializer for lifecycle */
- virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) = 0;
+ virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie) = 0;
};
/**
return op_target.obj_omap_set_val_by_key(dpp, key, val, must_exist);
}
- MPSerializer* DBObject::get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name)
+ std::unique_ptr<MPSerializer> DBObject::get_serializer(const DoutPrefixProvider *dpp,
+ const std::string& lock_name)
{
- return new MPDBSerializer(dpp, store, this, lock_name);
+ return std::make_unique<MPDBSerializer>(dpp, store, this, lock_name);
}
int DBObject::transition(Bucket* bucket,
return store->getDB()->put_head(oid, head);
}
- LCSerializer* DBLifecycle::get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie)
+ std::unique_ptr<LCSerializer> DBLifecycle::get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie)
{
- return new LCDBSerializer(store, oid, lock_name, cookie);
+ return std::make_unique<LCDBSerializer>(store, oid, lock_name, cookie);
}
std::unique_ptr<Notification> DBStore::get_notification(
virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
virtual int put_head(const std::string& oid, LCHead& head) override;
- virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
+ virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie) override;
};
class DBNotification : public StoreNotification {
virtual std::unique_ptr<Object> clone() override {
return std::unique_ptr<Object>(new DBObject(*this));
}
- virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) override;
+ virtual std::unique_ptr<MPSerializer> get_serializer(const DoutPrefixProvider *dpp,
+ const std::string& lock_name) override;
virtual int transition(Bucket* bucket,
const rgw_placement_rule& placement_rule,
const real_time& mtime,
return 0;
}
-MPSerializer* MotrObject::get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name)
+std::unique_ptr<MPSerializer> MotrObject::get_serializer(const DoutPrefixProvider *dpp,
+ const std::string& lock_name)
{
- return new MPMotrSerializer(dpp, store, this, lock_name);
+ return std::make_unique<MPMotrSerializer>(dpp, store, this, lock_name);
}
int MotrObject::transition(Bucket* bucket,
virtual std::unique_ptr<Object> clone() override {
return std::unique_ptr<Object>(new MotrObject(*this));
}
- virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) override;
+ virtual std::unique_ptr<MPSerializer> get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) override;
virtual int transition(Bucket* bucket,
const rgw_placement_rule& placement_rule,
const real_time& mtime,
return sysobj.omap().set_must_exist(must_exist).set(dpp, key, val, y);
}
-MPSerializer* RadosObject::get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name)
+std::unique_ptr<MPSerializer> RadosObject::get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name)
{
- return new MPRadosSerializer(dpp, store, this, lock_name);
+ return std::make_unique<MPRadosSerializer>(dpp, store, this, lock_name);
}
int RadosObject::transition(Bucket* bucket,
return cls_rgw_lc_put_head(*store->getRados()->get_lc_pool_ctx(), oid, cls_head);
}
-LCSerializer* RadosLifecycle::get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie)
+std::unique_ptr<LCSerializer> RadosLifecycle::get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie)
{
- return new LCRadosSerializer(store, oid, lock_name, cookie);
+ return std::make_unique<LCRadosSerializer>(store, oid, lock_name, cookie);
}
int RadosNotification::publish_reserve(const DoutPrefixProvider *dpp, RGWObjTags* obj_tags)
virtual std::unique_ptr<Object> clone() override {
return std::unique_ptr<Object>(new RadosObject(*this));
}
- virtual MPSerializer* get_serializer(const DoutPrefixProvider *dpp, const std::string& lock_name) override;
+ virtual std::unique_ptr<MPSerializer> get_serializer(const DoutPrefixProvider *dpp,
+ const std::string& lock_name) override;
virtual int transition(Bucket* bucket,
const rgw_placement_rule& placement_rule,
const real_time& mtime,
virtual int rm_entry(const std::string& oid, LCEntry& entry) override;
virtual int get_head(const std::string& oid, std::unique_ptr<LCHead>* head) override;
virtual int put_head(const std::string& oid, LCHead& head) override;
- virtual LCSerializer* get_serializer(const std::string& lock_name, const std::string& oid, const std::string& cookie) override;
+ virtual std::unique_ptr<LCSerializer> get_serializer(const std::string& lock_name,
+ const std::string& oid,
+ const std::string& cookie) override;
};
class RadosNotification : public StoreNotification {