From 5257d1a643fb1af36b80650ea2b014b4887dc10f Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 3 Feb 2017 13:12:47 -0800 Subject: [PATCH] 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 (cherry picked from commit 91b74235027c8a4872dcab6b37767b12c3267061) --- src/osd/PrimaryLogPG.cc | 12 ++++++------ src/osd/ReplicatedBackend.cc | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 57d09420743d9..904c15560cc1c 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 e63201dccc9bb..063887d00afe6 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()); } }; } -- 2.39.5