From 2db768f07dc078b68e345dd0b87382e0da9ec977 Mon Sep 17 00:00:00 2001 From: Adam Crume Date: Mon, 21 Jul 2014 10:36:51 -0700 Subject: [PATCH] rbd-replay: Fix memory leak in PendingIO Signed-off-by: Adam Crume --- src/rbd_replay/PendingIO.cc | 8 ++++++-- src/rbd_replay/PendingIO.hpp | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/rbd_replay/PendingIO.cc b/src/rbd_replay/PendingIO.cc index 09fa73c4ed063..28ae7a7bfa778 100644 --- a/src/rbd_replay/PendingIO.cc +++ b/src/rbd_replay/PendingIO.cc @@ -28,13 +28,17 @@ void pending_io_callback(librbd::completion_t cb, void *arg) { PendingIO::PendingIO(action_id_t id, ActionCtx &worker) : m_id(id), - m_completion(this, pending_io_callback), + m_completion(new librbd::RBD::AioCompletion(this, pending_io_callback)), m_worker(worker) { } +PendingIO::~PendingIO() { + m_completion->release(); +} + void PendingIO::completed(librbd::completion_t cb) { dout(ACTION_LEVEL) << "Completed pending IO #" << m_id << dendl; - ssize_t r = m_completion.get_return_value(); + ssize_t r = m_completion->get_return_value(); assertf(r >= 0, "id = %d, r = %d", m_id, r); m_worker.remove_pending(shared_from_this()); } diff --git a/src/rbd_replay/PendingIO.hpp b/src/rbd_replay/PendingIO.hpp index 7413a59cb5eab..3f0120744e9ef 100644 --- a/src/rbd_replay/PendingIO.hpp +++ b/src/rbd_replay/PendingIO.hpp @@ -27,6 +27,8 @@ public: PendingIO(action_id_t id, ActionCtx &worker); + ~PendingIO(); + void completed(librbd::completion_t cb); action_id_t id() const { @@ -38,13 +40,13 @@ public: } librbd::RBD::AioCompletion &completion() { - return m_completion; + return *m_completion; } private: const action_id_t m_id; ceph::bufferlist m_bl; - librbd::RBD::AioCompletion m_completion; + librbd::RBD::AioCompletion *m_completion; ActionCtx &m_worker; }; -- 2.39.5