mon: fix leak of loopback Connection

The accessor returns a reference.  Instead of taking+dropping it each
time, take one ref in Monitor ctor and release it in the dtor.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-06-05 08:53:38 -07:00
parent 08bb8d510b
commit a99435d06d
3 changed files with 5 additions and 1 deletions

View File

@ -119,6 +119,7 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s,
name(nm),
rank(-1),
messenger(m),
con_self(m ? m->get_loopback_connection() : NULL),
lock("Monitor::lock"),
timer(cct_, lock),
has_ever_joined(false),
@ -208,6 +209,8 @@ Monitor::~Monitor()
delete paxos;
assert(session_map.sessions.empty());
delete mon_caps;
if (con_self)
con_self->put();
}

View File

@ -108,6 +108,7 @@ public:
string name;
int rank;
Messenger *messenger;
Connection *con_self;
Mutex lock;
SafeTimer timer;

View File

@ -48,7 +48,7 @@ bool PaxosService::dispatch(PaxosServiceMessage *m)
// connection will be disconnected with a null message; don't drop
// those. also ignore loopback (e.g., log) messages.
if (!m->get_connection()->is_connected() &&
m->get_connection() != mon->messenger->get_loopback_connection() &&
m->get_connection() != mon->con_self &&
m->get_connection()->get_messenger() != NULL) {
dout(10) << " discarding message from disconnected client "
<< m->get_source_inst() << " " << *m << dendl;