Skip to content

Commit

Permalink
Merge pull request #13667 from jcsp/wip-mgr-misc
Browse files Browse the repository at this point in the history
mgr: use unique_ptr for MgrStandby::active_mgr

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Feb 28, 2017
2 parents 15cbb98 + 6ea42d7 commit 91c0937
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/mgr/MgrStandby.cc
Expand Up @@ -50,7 +50,6 @@ MgrStandby::~MgrStandby()
delete objecter;
delete monc;
delete client_messenger;
delete active_mgr;
}


Expand Down Expand Up @@ -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 {
Expand All @@ -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();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mgr/MgrStandby.h
Expand Up @@ -37,7 +37,7 @@ class MgrStandby : public Dispatcher {
Mutex lock;
SafeTimer timer;

Mgr *active_mgr;
std::unique_ptr<Mgr> active_mgr;

std::string state_str();

Expand Down

0 comments on commit 91c0937

Please sign in to comment.