]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: potential memory leak when attempting to cancel image sync
authorJason Dillaman <dillaman@redhat.com>
Tue, 19 Jul 2016 19:46:49 +0000 (15:46 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 17 Aug 2016 17:22:06 +0000 (13:22 -0400)
The cancel request could race with the actual scheduling of the image
sync operation.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit e6cdf955bad500561ddada2791641eba5fb27762)

src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc

index d1e64eb6c1b5ccb19c55f5f141d94c7a27827dee..574023a5267fdc1837ae973ead93dbf0c56213cf 100644 (file)
@@ -549,12 +549,22 @@ void BootstrapRequest<I>::image_sync() {
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_image_sync>(
       this);
 
-  m_image_sync_throttler->start_sync(*m_local_image_ctx,
-                                     m_remote_image_ctx, m_timer,
-                                     m_timer_lock,
-                                     m_local_mirror_uuid, m_journaler,
-                                     m_client_meta, m_work_queue, ctx,
-                                     m_progress_ctx);
+  {
+    Mutex::Locker locker(m_lock);
+    if (!m_canceled) {
+      m_image_sync_throttler->start_sync(*m_local_image_ctx,
+                                         m_remote_image_ctx, m_timer,
+                                         m_timer_lock,
+                                         m_local_mirror_uuid, m_journaler,
+                                         m_client_meta, m_work_queue, ctx,
+                                         m_progress_ctx);
+      return;
+    }
+  }
+
+  dout(10) << ": request canceled" << dendl;
+  m_ret_val = -ECANCELED;
+  close_remote_image();
 }
 
 template <typename I>