]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: use unique_ptr for MDSMap
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 2 Nov 2016 15:20:16 +0000 (11:20 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 14 Nov 2016 02:12:46 +0000 (21:12 -0500)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/client/Client.cc
src/client/Client.h

index 202478b4b014f5963d6ff9b9fd092ad6f5d86015..75a721a09cbf21cf194d1121ba904a4666a94237 100644 (file)
@@ -283,7 +283,7 @@ Client::Client(Messenger *m, MonClient *mc)
   messenger = m;
 
   // osd interfaces
-  mdsmap = new MDSMap;
+  mdsmap.reset(new MDSMap);
   objecter = new Objecter(cct, messenger, monclient, NULL,
                          0, 0);
   objecter->set_client_incarnation(0);  // client always 0, for now.
@@ -314,7 +314,6 @@ Client::~Client()
 
   delete filer;
   delete objecter;
-  delete mdsmap;
   delete fsmap;
 
   delete logger;
@@ -2546,8 +2545,9 @@ void Client::handle_mds_map(MMDSMap* m)
 
   ldout(cct, 1) << "handle_mds_map epoch " << m->get_epoch() << dendl;
 
-  MDSMap *oldmap = mdsmap;
-  mdsmap = new MDSMap;
+  std::unique_ptr<MDSMap> oldmap(new MDSMap);
+  oldmap.swap(mdsmap);
+
   mdsmap->decode(m->get_encoded());
 
   // Cancel any commands for missing or laggy GIDs
@@ -2619,7 +2619,6 @@ void Client::handle_mds_map(MMDSMap* m)
   // kick any waiting threads
   signal_cond_list(waiting_for_mdsmap);
 
-  delete oldmap;
   m->put();
 
   monclient->sub_got("mdsmap", mdsmap->get_epoch());
index 636de56f27beb07c2c1ef72dfa25c4330f3cc8aa..9aa231a5704fd70b503c5cb8209bc3abea17585d 100644 (file)
@@ -264,7 +264,7 @@ class Client : public Dispatcher, public md_config_obs_t {
   CommandHook m_command_hook;
 
   // cluster descriptors
-  MDSMap *mdsmap;
+  std::unique_ptr<MDSMap> mdsmap;
 
   SafeTimer timer;