From d9747541b9f449ab758e0100ed1ce331823212f0 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 24 Sep 2018 16:54:33 -0700 Subject: [PATCH] rgw: don't use self_ref Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_tools.cc | 2 +- src/rgw/rgw_tools.h | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 0888bab7672..8b7b5642949 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -320,7 +320,7 @@ int RGWDataAccess::Bucket::init(const RGWBucketInfo& _bucket_info, int RGWDataAccess::Bucket::get_object(const rgw_obj_key& key, ObjectRef *obj) { - obj->reset(new Object(sd, self_ref, key)); + obj->reset(new Object(sd, shared_from_this(), key)); return 0; } diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index 59afa8357bf..1ca2452a6f1 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -96,12 +96,10 @@ public: using BucketRef = std::shared_ptr; using ObjectRef = std::shared_ptr; - class Bucket { + class Bucket : public enable_shared_from_this { friend class RGWDataAccess; friend class Object; - std::shared_ptr self_ref; - RGWDataAccess *sd{nullptr}; RGWBucketInfo bucket_info; string tenant; @@ -144,7 +142,7 @@ public: std::optional aclbl; Object(RGWDataAccess *_sd, - BucketRef& _bucket, + BucketRef&& _bucket, const rgw_obj_key& _key) : sd(_sd), bucket(_bucket), key(_key) {} @@ -181,7 +179,6 @@ public: const string bucket_id, BucketRef *bucket) { bucket->reset(new Bucket(this, tenant, name, bucket_id)); - (*bucket)->self_ref = *bucket; return (*bucket)->init(); } @@ -189,7 +186,6 @@ public: const map& attrs, BucketRef *bucket) { bucket->reset(new Bucket(this)); - (*bucket)->self_ref = *bucket; return (*bucket)->init(bucket_info, attrs); } friend class Bucket; -- 2.39.5