From 4828b2f205898358c1c81f6a56ebd10aa28685b3 Mon Sep 17 00:00:00 2001 From: xie xingguo Date: Tue, 14 Jun 2016 20:29:53 +0800 Subject: [PATCH] mds: cancel context correctly if we already have required osdmap in hand By simply deleting the fin, the callbacks will be requeued into the specified finisher and recalled later, which is not the expected behaviour. Signed-off-by: xie xingguo --- src/common/Finisher.h | 9 +++++++++ src/mds/MDSContext.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/common/Finisher.h b/src/common/Finisher.h index 4d494ed15333d..ffdddf632e8d3 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -173,8 +173,17 @@ public: assert(fin != NULL); assert(con != NULL); } + + ~C_OnFinisher() { + if (con != nullptr) { + delete con; + con = nullptr; + } + } + void finish(int r) { fin->queue(con, r); + con = nullptr; } }; diff --git a/src/mds/MDSContext.h b/src/mds/MDSContext.h index d26d1bdb783a6..a69223dc7b3eb 100644 --- a/src/mds/MDSContext.h +++ b/src/mds/MDSContext.h @@ -135,8 +135,17 @@ public: C_IO_Wrapper(MDSRank *mds_, MDSInternalContextBase *wrapped_) : MDSIOContext(mds_), wrapped(wrapped_) { assert(wrapped != NULL); } + + ~C_IO_Wrapper() { + if (wrapped != nullptr) { + delete wrapped; + wrapped = nullptr; + } + } + virtual void finish(int r) { wrapped->complete(r); + wrapped = nullptr; } }; -- 2.39.5