From: Patrick Donnelly Date: Wed, 2 Nov 2016 15:20:16 +0000 (-0400) Subject: client: use unique_ptr for MDSMap X-Git-Tag: v11.1.0~276^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=25ab2b6dc7764bc62438294d553df7ede756dd03;p=ceph-ci.git client: use unique_ptr for MDSMap Signed-off-by: Patrick Donnelly --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 202478b4b01..75a721a09cb 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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 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()); diff --git a/src/client/Client.h b/src/client/Client.h index 636de56f27b..9aa231a5704 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -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; SafeTimer timer;