From 6ea42d79ae1f6434b2b4684bba837b541c3952af Mon Sep 17 00:00:00 2001 From: John Spray Date: Sat, 4 Feb 2017 21:14:13 +0000 Subject: [PATCH] mgr: use unique_ptr for MgrStandby::active_mgr It should always have been one of these. Signed-off-by: John Spray --- src/mgr/MgrStandby.cc | 8 +++----- src/mgr/MgrStandby.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 92cb8013a7f75..8e460e1ac982e 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 0762764cdc5b9..d347cb6905555 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(); -- 2.39.5