]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use shared_ptr instead of RefCountedObject
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 1 May 2013 22:40:44 +0000 (15:40 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 8 May 2013 18:22:08 +0000 (11:22 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_bucket.cc
src/rgw/rgw_bucket.h

index e6f985c45e4ccd241608c9e6b6db67d7264187f7..646176e1147ed3c3c678d9833a9644a9a190ab9c 100644 (file)
@@ -1057,12 +1057,11 @@ int RGWDataChangesLog::choose_oid(rgw_bucket& bucket) {
 
 int RGWDataChangesLog::add_entry(rgw_bucket& bucket) {
   lock.Lock();
-  ChangeStatus *& status = changes[bucket.name];
+  ChangeStatusPtr& status = changes[bucket.name];
   if (!status) {
-    status = new ChangeStatus;
+    status = ChangeStatusPtr(new ChangeStatus);
   }
 
-  status->get();
   lock.Unlock();
 
   utime_t now = ceph_clock_now(cct);
@@ -1073,7 +1072,6 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket) {
   if (now < status->cur_expiration) {
     /* no need to send, recently completed */
     status->lock->Unlock();
-    status->put();
     return 0;
   }
 
@@ -1086,7 +1084,6 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket) {
 
     status->cond->get();
     status->lock->Unlock();
-    status->put();
 
     cond->wait();
     cond->put();
@@ -1122,8 +1119,6 @@ int RGWDataChangesLog::add_entry(rgw_bucket& bucket) {
   status->cond = NULL;
   status->lock->Unlock();
 
-  status->put();
-
   cond->done();
   cond->put();
 
index 7c4c3d3c6cb5ee9034ddfef199fbf00b57ecd0b5..b8492b54a3df5c46c0b82a773510ba4ac126ca7d 100644 (file)
@@ -2,6 +2,7 @@
 #define CEPH_RGW_BUCKET_H
 
 #include <string>
+#include <memory>
 
 #include "include/types.h"
 #include "rgw_common.h"
@@ -258,7 +259,7 @@ class RGWDataChangesLog {
 
   Mutex lock;
 
-  struct ChangeStatus : public RefCountedObject {
+  struct ChangeStatus {
     utime_t cur_expiration;
     utime_t cur_sent;
     bool pending;
@@ -274,7 +275,9 @@ class RGWDataChangesLog {
     }
   };
 
-  map<string, ChangeStatus *> changes;
+  typedef std::tr1::shared_ptr<ChangeStatus> ChangeStatusPtr;
+
+  map<string, ChangeStatusPtr> changes;
 
 public: