]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/: don't leak context for Blessed*Context or RecoveryQueueAsync
authorSamuel Just <sjust@redhat.com>
Fri, 3 Feb 2017 21:12:47 +0000 (13:12 -0800)
committerSamuel Just <sjust@redhat.com>
Fri, 3 Feb 2017 21:12:47 +0000 (13:12 -0800)
This has always been a bug, but until
68defc2b0561414711d4dd0a76bc5d0f46f8a3f8, nothing deleted those contexts
without calling complete().

Fixes: http://tracker.ceph.com/issues/18809
Bug shadowed until: 68defc2b0561414711d4dd0a76bc5d0f46f8a3f8
Signed-off-by: Samuel Just <sjust@redhat.com>
src/osd/PrimaryLogPG.cc
src/osd/ReplicatedBackend.cc

index fbd5fa4f00b712b7782f3973ed3d24b935c0e2c8..0f2c33d16a0ba74759a94dc675c3364f71ecfd04 100644 (file)
@@ -124,7 +124,7 @@ public:
 template <typename T>
 class PrimaryLogPG::BlessedGenContext : public GenContext<T> {
   PrimaryLogPGRef pg;
-  GenContext<T> *c;
+  unique_ptr<GenContext<T>> c;
   epoch_t e;
 public:
   BlessedGenContext(PrimaryLogPG *pg, GenContext<T> *c, epoch_t e)
@@ -132,9 +132,9 @@ public:
   void finish(T t) {
     pg->lock();
     if (pg->pg_has_reset_since(e))
-      delete c;
+      c.reset();
     else
-      c->complete(t);
+      c.release()->complete(t);
     pg->unlock();
   }
 };
@@ -147,7 +147,7 @@ GenContext<ThreadPool::TPHandle&> *PrimaryLogPG::bless_gencontext(
 
 class PrimaryLogPG::BlessedContext : public Context {
   PrimaryLogPGRef pg;
-  Context *c;
+  unique_ptr<Context> c;
   epoch_t e;
 public:
   BlessedContext(PrimaryLogPG *pg, Context *c, epoch_t e)
@@ -155,9 +155,9 @@ public:
   void finish(int r) {
     pg->lock();
     if (pg->pg_has_reset_since(e))
-      delete c;
+      c.reset();
     else
-      c->complete(r);
+      c.release()->complete(r);
     pg->unlock();
   }
 };
index 070bbbf0150ef6e74110ffeb781a9541e3a9a4d0..3d49f837b56b976a7fc6494a86007119d49f808d 100644 (file)
@@ -47,13 +47,13 @@ class PG_SendMessageOnConn: public Context {
 
 class PG_RecoveryQueueAsync : public Context {
   PGBackend::Listener *pg;
-  GenContext<ThreadPool::TPHandle&> *c;
+  unique_ptr<GenContext<ThreadPool::TPHandle&>> c;
   public:
   PG_RecoveryQueueAsync(
     PGBackend::Listener *pg,
     GenContext<ThreadPool::TPHandle&> *c) : pg(pg), c(c) {}
   void finish(int) {
-    pg->schedule_recovery_work(c);
+    pg->schedule_recovery_work(c.release());
   }
 };
 }