From: Samuel Just Date: Fri, 3 Feb 2017 21:12:47 +0000 (-0800) Subject: osd/: don't leak context for Blessed*Context or RecoveryQueueAsync X-Git-Tag: v12.0.1~446^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F13342%2Fhead;p=ceph.git osd/: don't leak context for Blessed*Context or RecoveryQueueAsync 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 --- diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index fbd5fa4f00b7..0f2c33d16a0b 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -124,7 +124,7 @@ public: template class PrimaryLogPG::BlessedGenContext : public GenContext { PrimaryLogPGRef pg; - GenContext *c; + unique_ptr> c; epoch_t e; public: BlessedGenContext(PrimaryLogPG *pg, GenContext *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 *PrimaryLogPG::bless_gencontext( class PrimaryLogPG::BlessedContext : public Context { PrimaryLogPGRef pg; - Context *c; + unique_ptr 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(); } }; diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 070bbbf0150e..3d49f837b56b 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -47,13 +47,13 @@ class PG_SendMessageOnConn: public Context { class PG_RecoveryQueueAsync : public Context { PGBackend::Listener *pg; - GenContext *c; + unique_ptr> c; public: PG_RecoveryQueueAsync( PGBackend::Listener *pg, GenContext *c) : pg(pg), c(c) {} void finish(int) { - pg->schedule_recovery_work(c); + pg->schedule_recovery_work(c.release()); } }; }