From: Adam Crume Date: Mon, 21 Jul 2014 17:36:51 +0000 (-0700) Subject: rbd-replay: Fix memory leak in PendingIO X-Git-Tag: v0.86~231^2~52 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2db768f07dc078b68e345dd0b87382e0da9ec977;p=ceph.git rbd-replay: Fix memory leak in PendingIO Signed-off-by: Adam Crume --- diff --git a/src/rbd_replay/PendingIO.cc b/src/rbd_replay/PendingIO.cc index 09fa73c4ed06..28ae7a7bfa77 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 7413a59cb5ea..3f0120744e9e 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; };