From e4bc16044e1b80636855dbc39da1d121a3508308 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 14 Jul 2016 13:38:44 -0400 Subject: [PATCH] rgw: RGWMetaSyncCR holds refs to stacks for wakeup because RGWCoroutine::wakeup() calls RGWCoroutinesStack::wakeup(), the stack must also stay alive Fixes: http://tracker.ceph.com/issues/16666 Signed-off-by: Casey Bodley --- src/rgw/rgw_sync.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index c53a2cd5da649..474e2c558d87f 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -1668,8 +1668,13 @@ class RGWMetaSyncCR : public RGWCoroutine { std::mutex mutex; //< protect access to shard_crs + // TODO: it should be enough to hold a reference on the stack only, as calling + // RGWCoroutinesStack::wakeup() doesn't refer to the RGWCoroutine if it has + // already completed using ControlCRRef = boost::intrusive_ptr; - map shard_crs; + using StackRef = boost::intrusive_ptr; + using RefPair = std::pair; + map shard_crs; public: RGWMetaSyncCR(RGWMetaSyncEnv *_sync_env, RGWPeriodHistory::Cursor cursor, @@ -1727,8 +1732,8 @@ class RGWMetaSyncCR : public RGWCoroutine { auto cr = new RGWMetaSyncShardControlCR(sync_env, pool, period_id, mdlog, shard_id, marker, std::move(period_marker)); - shard_crs[shard_id] = cr; - spawn(cr, false); + auto stack = spawn(cr, false); + shard_crs[shard_id] = RefPair{cr, stack}; } } // wait for each shard to complete @@ -1764,7 +1769,7 @@ class RGWMetaSyncCR : public RGWCoroutine { if (iter == shard_crs.end()) { return; } - iter->second->wakeup(); + iter->second.first->wakeup(); } };