From 9ffa3e20bd66cf357de53119b222aefa924cb29b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 7 Jan 2016 15:08:13 -0800 Subject: [PATCH] rgw: fix a few leaks Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_coroutine.cc | 10 ++++++++++ src/rgw/rgw_coroutine.h | 1 + src/rgw/rgw_data_sync.cc | 23 +++++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_coroutine.cc b/src/rgw/rgw_coroutine.cc index 051e92ea5a7df..107102848f22a 100644 --- a/src/rgw/rgw_coroutine.cc +++ b/src/rgw/rgw_coroutine.cc @@ -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& stacks) } lock.get_write(); + for (auto stack : context_stacks) { + stack->put(); + } run_contexts.erase(run_context); lock.unlock(); diff --git a/src/rgw/rgw_coroutine.h b/src/rgw/rgw_coroutine.h index 3f8dc3a58c804..c976ed7e3fcb6 100644 --- a/src/rgw/rgw_coroutine.h +++ b/src/rgw/rgw_coroutine.h @@ -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); diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index cdc46cce2c2e5..cfe1199403e36 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -65,6 +65,8 @@ class RGWReadDataSyncStatusCoroutine : public RGWSimpleRadosReadCR 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& markers = sync_status->sync_markers; for (int i = 0; i < (int)data.num_shards; i++) { - spawn(new RGWSimpleRadosReadCR(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(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); } -- 2.39.5