]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-kvstore-tool: clean up destination store object
authorJosh Durgin <jdurgin@redhat.com>
Tue, 26 Sep 2017 02:33:31 +0000 (19:33 -0700)
committerJosh Durgin <jdurgin@redhat.com>
Wed, 4 Apr 2018 14:12:43 +0000 (10:12 -0400)
If left alive, background threads in the db may crash

Signed-off-by: Josh Durgin <jdurgin@redhat.com>
(cherry picked from commit 718fc15831a2cb4eb91ed2aa2f694b47329f9189)

src/tools/ceph_kvstore_tool.cc

index 1a9af24108b408598832f5ff746d5f588c20c889..b8ce4563132ab5a98ab8d42aeaf94c4266cd8dab 100644 (file)
@@ -150,10 +150,12 @@ class StoreTool
     }
 
     // open or create a leveldb store at @p other_path
-    KeyValueDB *other = KeyValueDB::create(g_ceph_context, other_type, other_path);
-    int err = other->create_and_open(std::cerr);
+    boost::scoped_ptr<KeyValueDB> other;
+    KeyValueDB *other_ptr = KeyValueDB::create(g_ceph_context, other_type, other_path);
+    int err = other_ptr->create_and_open(std::cerr);
     if (err < 0)
       return err;
+    other.reset(other_ptr);
 
     KeyValueDB::WholeSpaceIterator it = db->get_iterator();
     it->seek_to_first();