]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: use unique_ptr for MgrStandby::active_mgr 13667/head
authorJohn Spray <john.spray@redhat.com>
Sat, 4 Feb 2017 21:14:13 +0000 (21:14 +0000)
committerJohn Spray <john.spray@redhat.com>
Mon, 27 Feb 2017 11:11:28 +0000 (11:11 +0000)
It should always have been one of these.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/MgrStandby.cc
src/mgr/MgrStandby.h

index 92cb8013a7f7507779b89b8b3dcd7eee2e67f37a..8e460e1ac982e86fc33bb906f3eecb7846c6d904 100644 (file)
@@ -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();
     }
   }
 }
index 0762764cdc5b913d9e21926e05ab9c62816ba0f5..d347cb6905555f700c8ccc980a12bc2994d34fa2 100644 (file)
@@ -37,7 +37,7 @@ protected:
   Mutex lock;
   SafeTimer timer;
 
-  Mgr *active_mgr;
+  std::unique_ptr<Mgr> active_mgr;
 
   std::string state_str();