From: John Spray Date: Sat, 4 Feb 2017 21:14:13 +0000 (+0000) Subject: mgr: use unique_ptr for MgrStandby::active_mgr X-Git-Tag: v12.0.1~234^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F13667%2Fhead;p=ceph.git mgr: use unique_ptr for MgrStandby::active_mgr It should always have been one of these. Signed-off-by: John Spray --- diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 92cb8013a7f..8e460e1ac98 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -50,7 +50,6 @@ MgrStandby::~MgrStandby() delete objecter; delete monc; delete client_messenger; - delete active_mgr; } @@ -159,9 +158,9 @@ void MgrStandby::handle_mgr_map(MMgrMap* mmap) dout(4) << "active in map: " << active_in_map << " active is " << map.active_gid << dendl; if (active_in_map) { - if (active_mgr == nullptr) { + if (!active_mgr) { dout(1) << "Activating!" << dendl; - active_mgr = new Mgr(monc, client_messenger, objecter); + active_mgr.reset(new Mgr(monc, client_messenger, objecter)); active_mgr->background_init(); dout(1) << "I am now active" << dendl; } else { @@ -171,8 +170,7 @@ void MgrStandby::handle_mgr_map(MMgrMap* mmap) if (active_mgr != nullptr) { derr << "I was active but no longer am" << dendl; active_mgr->shutdown(); - delete active_mgr; - active_mgr = nullptr; + active_mgr.reset(); } } } diff --git a/src/mgr/MgrStandby.h b/src/mgr/MgrStandby.h index 0762764cdc5..d347cb69055 100644 --- a/src/mgr/MgrStandby.h +++ b/src/mgr/MgrStandby.h @@ -37,7 +37,7 @@ protected: Mutex lock; SafeTimer timer; - Mgr *active_mgr; + std::unique_ptr active_mgr; std::string state_str();