]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: free memory after image deleter fails to open image
authorJason Dillaman <dillaman@redhat.com>
Wed, 22 Nov 2017 02:19:35 +0000 (21:19 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 19 Dec 2017 14:09:12 +0000 (09:09 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_deleter/test_mock_SnapshotPurgeRequest.cc
src/tools/rbd_mirror/image_deleter/SnapshotPurgeRequest.cc

index bf312135d60ae225e103d49004e2037e36ff8374..370b6d2942519fa651904d829e9f56a50de03ae4 100644 (file)
@@ -218,6 +218,7 @@ TEST_F(TestMockImageDeleterSnapshotPurgeRequest, OpenError) {
   InSequence seq;
   expect_set_journal_policy(mock_image_ctx);
   expect_open(mock_image_ctx, -EPERM);
+  expect_destroy(mock_image_ctx);
 
   C_SaferCond ctx;
   auto req = MockSnapshotPurgeRequest::create(m_local_io_ctx, mock_image_ctx.id,
index 8d2350decf3a18e4e36c7034fbc46eb571b92590..80e46101daaafbc53401bdbf316b41cdbe923cfb 100644 (file)
@@ -67,6 +67,9 @@ void SnapshotPurgeRequest<I>::handle_open_image(int r) {
   if (r < 0) {
     derr << "failed to open image '" << m_image_id << "': " << cpp_strerror(r)
          << dendl;
+    m_image_ctx->destroy();
+    m_image_ctx = nullptr;
+
     finish(r);
     return;
   }