]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: RGWMetaSyncCR holds refs to stacks for wakeup 10662/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 14 Jul 2016 17:38:44 +0000 (13:38 -0400)
committerLoic Dachary <ldachary@redhat.com>
Wed, 10 Aug 2016 12:24:39 +0000 (14:24 +0200)
because RGWCoroutine::wakeup() calls RGWCoroutinesStack::wakeup(), the
stack must also stay alive

Fixes: http://tracker.ceph.com/issues/16666
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e4bc16044e1b80636855dbc39da1d121a3508308)

src/rgw/rgw_sync.cc

index dab98fce5910855df136079af8fd9b69c2b1f593..69a31ba08b0000315d5a2113ccdde5d2e647aab9 100644 (file)
@@ -1661,8 +1661,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<RGWMetaSyncShardControlCR>;
-  map<int, ControlCRRef> shard_crs;
+  using StackRef = boost::intrusive_ptr<RGWCoroutinesStack>;
+  using RefPair = std::pair<ControlCRRef, StackRef>;
+  map<int, RefPair> shard_crs;
 
 public:
   RGWMetaSyncCR(RGWMetaSyncEnv *_sync_env, RGWPeriodHistory::Cursor cursor,
@@ -1720,8 +1725,8 @@ public:
             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
@@ -1757,7 +1762,7 @@ public:
     if (iter == shard_crs.end()) {
       return;
     }
-    iter->second->wakeup();
+    iter->second.first->wakeup();
   }
 };