]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-replay: Fix memory leak in PendingIO
authorAdam Crume <adamcrume@gmail.com>
Mon, 21 Jul 2014 17:36:51 +0000 (10:36 -0700)
committerSage Weil <sage@redhat.com>
Thu, 21 Aug 2014 17:57:30 +0000 (10:57 -0700)
Signed-off-by: Adam Crume <adamcrume@gmail.com>
src/rbd_replay/PendingIO.cc
src/rbd_replay/PendingIO.hpp

index 09fa73c4ed0635f01de7129858eb31f65a97efc8..28ae7a7bfa778b42df77e811c01dfb45fcc0f6d2 100644 (file)
@@ -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());
 }
index 7413a59cb5eabfe587cd651e717e78d5c1de8633..3f0120744e9ef6c130f8347ee49972d9194d3fbb 100644 (file)
@@ -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;
 };