From: Sage Weil Date: Wed, 5 Jun 2013 15:53:38 +0000 (-0700) Subject: mon: fix leak of loopback Connection X-Git-Tag: v0.64~10^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a99435d06d923462ca9277d4a55d8a851c647ffc;p=ceph.git 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 --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 72fd3777a8ca..dbd02d5bd782 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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(); } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index b9203ae1e615..f84efe379b54 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -108,6 +108,7 @@ public: string name; int rank; Messenger *messenger; + Connection *con_self; Mutex lock; SafeTimer timer; diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 8840fcecc357..c32e77fee31a 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -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;