]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix a few leaks
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 7 Jan 2016 23:08:13 +0000 (15:08 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:53 +0000 (16:13 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_coroutine.cc
src/rgw/rgw_coroutine.h
src/rgw/rgw_data_sync.cc

index 051e92ea5a7df85e06d6b46d63b1ff0035980994..107102848f22aa03533fa2b900a79b0319a98c76 100644 (file)
@@ -137,6 +137,13 @@ RGWCoroutinesStack::RGWCoroutinesStack(CephContext *_cct, RGWCoroutinesManager *
   pos = ops.begin();
 }
 
+RGWCoroutinesStack::~RGWCoroutinesStack()
+{
+  for (auto op : ops) {
+    op->put();
+  }
+}
+
 int RGWCoroutinesStack::operate(RGWCoroutinesEnv *_env)
 {
   env = _env;
@@ -517,6 +524,9 @@ int RGWCoroutinesManager::run(list<RGWCoroutinesStack *>& stacks)
   }
 
   lock.get_write();
+  for (auto stack : context_stacks) {
+    stack->put();
+  }
   run_contexts.erase(run_context);
   lock.unlock();
 
index 3f8dc3a58c80457f0ccc94ea994cb95894224641..c976ed7e3fcb626185e2daed20cdba538ceec0f1 100644 (file)
@@ -339,6 +339,7 @@ protected:
   bool collect_next(RGWCoroutine *op, int *ret, RGWCoroutinesStack **collected_stack); /* returns true if found a stack to collect */
 public:
   RGWCoroutinesStack(CephContext *_cct, RGWCoroutinesManager *_ops_mgr, RGWCoroutine *start = NULL);
+  ~RGWCoroutinesStack();
 
   int operate(RGWCoroutinesEnv *env);
 
index cdc46cce2c2e50f05d9a2fabebd0919cd5097579..cfe1199403e36a38a993a70e715599b200a03178 100644 (file)
@@ -65,6 +65,8 @@ class RGWReadDataSyncStatusCoroutine : public RGWSimpleRadosReadCR<rgw_data_sync
 
   rgw_data_sync_status *sync_status;
 
+  list<RGWCoroutinesStack *> crs;
+
 public:
   RGWReadDataSyncStatusCoroutine(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store,
                      RGWObjectCtx& _obj_ctx, const string& _source_zone,
@@ -76,6 +78,11 @@ public:
                                                                             obj_ctx(_obj_ctx), source_zone(_source_zone),
                                                                            sync_status(_status) {}
 
+  ~RGWReadDataSyncStatusCoroutine() {
+    for (auto cr : crs) {
+      cr->put();
+    }
+  }
   int handle_data(rgw_data_sync_info& data);
 };
 
@@ -87,8 +94,9 @@ int RGWReadDataSyncStatusCoroutine::handle_data(rgw_data_sync_info& data)
 
   map<uint32_t, rgw_data_sync_marker>& markers = sync_status->sync_markers;
   for (int i = 0; i < (int)data.num_shards; i++) {
-    spawn(new RGWSimpleRadosReadCR<rgw_data_sync_marker>(async_rados, store, obj_ctx, store->get_zone_params().log_pool,
-                                                   RGWDataSyncStatusManager::shard_obj_name(source_zone, i), &markers[i]), true);
+    RGWCoroutinesStack *cr = spawn(new RGWSimpleRadosReadCR<rgw_data_sync_marker>(async_rados, store, obj_ctx, store->get_zone_params().log_pool,
+                                                    RGWDataSyncStatusManager::shard_obj_name(source_zone, i), &markers[i]), true);
+    crs.push_back(cr);
   }
   return 0;
 }
@@ -115,6 +123,12 @@ public:
                                                       shard_info(_shard_info) {
   }
 
+  ~RGWReadRemoteDataLogShardInfoCR() {
+    if (http_op) {
+      http_op->put();
+    }
+  }
+
   int operate() {
     reenter(this) {
       yield {
@@ -135,7 +149,6 @@ public:
         if (ret < 0) {
           ldout(store->ctx(), 0) << "ERROR: failed to read from " << p << dendl;
           log_error() << "failed to send http operation: " << http_op->to_str() << " ret=" << ret << std::endl;
-          http_op->put();
           return set_cr_error(ret);
         }
 
@@ -193,6 +206,9 @@ public:
                                                       pmarker(_pmarker),
                                                       entries(_entries),
                                                       truncated(_truncated) {
+    if (http_op) {
+      http_op->put();
+    }
   }
 
   int operate() {
@@ -216,7 +232,6 @@ public:
         if (ret < 0) {
           ldout(store->ctx(), 0) << "ERROR: failed to read from " << p << dendl;
           log_error() << "failed to send http operation: " << http_op->to_str() << " ret=" << ret << std::endl;
-          http_op->put();
           return set_cr_error(ret);
         }