]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: memory leak possible if journal op event failed 10055/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 23 Jun 2016 13:03:24 +0000 (09:03 -0400)
committerLoic Dachary <ldachary@redhat.com>
Thu, 30 Jun 2016 07:56:37 +0000 (09:56 +0200)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit f5069750849c2c43caa4bff766301169a4bfc6ca)

src/librbd/journal/Replay.cc

index f1da0987de16c3a8a9d2ef313d7117c31b2e9ef5..dfbc546c6c27cd631ba80531a728664bf5f0fdb5 100644 (file)
@@ -108,24 +108,29 @@ struct C_RefreshIfRequired : public Context {
   C_RefreshIfRequired(I &image_ctx, Context *on_finish)
     : image_ctx(image_ctx), on_finish(on_finish) {
   }
+  virtual ~C_RefreshIfRequired() {
+    delete on_finish;
+  }
 
   virtual void finish(int r) override {
     CephContext *cct = image_ctx.cct;
+    Context *ctx = on_finish;
+    on_finish = nullptr;
 
     if (r < 0) {
       lderr(cct) << "C_RefreshIfRequired: " << __func__ << ": r=" << r << dendl;
-      image_ctx.op_work_queue->queue(on_finish, r);
+      image_ctx.op_work_queue->queue(ctx, r);
       return;
     }
 
     if (image_ctx.state->is_refresh_required()) {
       ldout(cct, 20) << "C_RefreshIfRequired: " << __func__ << ": "
                      << "refresh required" << dendl;
-      image_ctx.state->refresh(on_finish);
+      image_ctx.state->refresh(ctx);
       return;
     }
 
-    image_ctx.op_work_queue->queue(on_finish, 0);
+    image_ctx.op_work_queue->queue(ctx, 0);
   }
 };