]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix deletion of index completion object
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 17 May 2017 21:50:53 +0000 (14:50 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 5 Jun 2017 20:17:48 +0000 (13:17 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index 0b05353bd1fe7d1ab1818c8501486fab8c2c40d8..90b3f040afbe4d7f7322ccc0ba4f085db961253c 100644 (file)
@@ -3525,7 +3525,7 @@ public:
                          list<cls_rgw_obj_key>& remove_objs, bool log_op,
                          uint16_t bilog_op,
                          complete_op_data **result);
-  void handle_completion(completion_t cb, complete_op_data *arg);
+  bool handle_completion(completion_t cb, complete_op_data *arg);
 
   int start() {
     completion_thread = new RGWIndexCompletionThread(store);
@@ -3560,9 +3560,13 @@ static void obj_complete_cb(completion_t cb, void *arg)
   if (completion->stopped) {
     completion->lock.Unlock(); /* can drop lock, no one else is referencing us */
     delete completion;
+    return;
   }
-  ((complete_op_data *)arg)->manager->handle_completion(cb, completion);
+  bool need_delete = completion->manager->handle_completion(cb, completion);
   completion->lock.Unlock();
+  if (need_delete) {
+    delete completion;
+  }
 }
 
 
@@ -3599,7 +3603,7 @@ void RGWIndexCompletionManager::create_completion(const rgw_obj& obj,
   completions[shard_id].insert(entry);
 }
 
-void RGWIndexCompletionManager::handle_completion(completion_t cb, complete_op_data *arg)
+bool RGWIndexCompletionManager::handle_completion(completion_t cb, complete_op_data *arg)
 {
   int shard_id = arg->manager_shard_id;
   {
@@ -3609,7 +3613,7 @@ void RGWIndexCompletionManager::handle_completion(completion_t cb, complete_op_d
 
     auto iter = comps.find(arg);
     if (iter == comps.end()) {
-      return;
+      return true;
     }
 
     comps.erase(iter);
@@ -3617,10 +3621,10 @@ void RGWIndexCompletionManager::handle_completion(completion_t cb, complete_op_d
 
   int r = rados_aio_get_return_value(cb);
   if (r != -ERR_BUSY_RESHARDING) {
-    delete arg;
-    return;
+    return true;
   }
   completion_thread->add_completion(arg);
+  return false;
 }
 
 void RGWRados::finalize()