From: Jason Dillaman Date: Tue, 19 Jul 2016 19:46:49 +0000 (-0400) Subject: rbd-mirror: potential memory leak when attempting to cancel image sync X-Git-Tag: v10.2.3~50^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d47a23272765633df2303e142d67d78af5bd2bf4;p=ceph.git rbd-mirror: potential memory leak when attempting to cancel image sync The cancel request could race with the actual scheduling of the image sync operation. Signed-off-by: Jason Dillaman (cherry picked from commit e6cdf955bad500561ddada2791641eba5fb27762) --- diff --git a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc index d1e64eb6c1b..574023a5267 100644 --- a/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc +++ b/src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc @@ -549,12 +549,22 @@ void BootstrapRequest::image_sync() { BootstrapRequest, &BootstrapRequest::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