summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@redhat.com>2014-08-21 23:58:24 +0200
committerSage Weil <sage@redhat.com>2014-08-21 23:58:24 +0200
commit0b1a4328bd0f745d967dce04c5289560254acfea (patch)
tree50cd5789e19639845fb1958825817c841d61bc80
parentMerge remote-tracking branch 'gh/next' (diff)
parentmon: make dispatch(), _ms_dispatch() void (diff)
downloadceph-0b1a4328bd0f745d967dce04c5289560254acfea.tar.xz
ceph-0b1a4328bd0f745d967dce04c5289560254acfea.zip
Merge pull request #2301 from ceph/wip-9176
mon: fix occasional memory leak; clean up dispatch return codes Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r--src/mon/Monitor.cc29
-rw-r--r--src/mon/Monitor.h8
2 files changed, 17 insertions, 20 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 1c75c74268c..c8fa7c4ae76 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -2895,13 +2895,11 @@ void Monitor::waitlist_or_zap_client(Message *m)
}
}
-bool Monitor::_ms_dispatch(Message *m)
+void Monitor::_ms_dispatch(Message *m)
{
- bool ret = true;
-
if (is_shutdown()) {
m->put();
- return true;
+ return;
}
ConnectionRef connection = m->get_connection();
@@ -2939,13 +2937,14 @@ bool Monitor::_ms_dispatch(Message *m)
return dispatch(s, m, false);
}
dout(1) << __func__ << " dropping stray message " << *m
- << " from " << m->get_source_inst() << dendl;
- return false;
+ << " from " << m->get_source_inst() << dendl;
+ m->put();
+ return;
}
if (!exited_quorum.is_zero() && !src_is_mon) {
waitlist_or_zap_client(m);
- return true;
+ return;
}
dout(10) << "do not have session, making new one" << dendl;
@@ -2984,22 +2983,20 @@ bool Monitor::_ms_dispatch(Message *m)
if (is_synchronizing() && !src_is_mon) {
waitlist_or_zap_client(m);
- return true;
+ return;
}
- ret = dispatch(s, m, src_is_mon);
+ dispatch(s, m, src_is_mon);
if (s) {
s->put();
}
- return ret;
+ return;
}
-bool Monitor::dispatch(MonSession *s, Message *m, const bool src_is_mon)
+void Monitor::dispatch(MonSession *s, Message *m, const bool src_is_mon)
{
- bool ret = true;
-
assert(m != NULL);
switch (m->get_type()) {
@@ -3158,10 +3155,10 @@ bool Monitor::dispatch(MonSession *s, Message *m, const bool src_is_mon)
break;
default:
- ret = false;
+ dout(1) << "dropping unexpected " << *m << dendl;
+ m->put();
+ break;
}
-
- return ret;
}
void Monitor::handle_ping(MPing *m)
diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h
index 5c8671c465b..55c4e218d46 100644
--- a/src/mon/Monitor.h
+++ b/src/mon/Monitor.h
@@ -750,15 +750,15 @@ public:
//ms_dispatch handles a lot of logic and we want to reuse it
//on forwarded messages, so we create a non-locking version for this class
- bool _ms_dispatch(Message *m);
+ void _ms_dispatch(Message *m);
bool ms_dispatch(Message *m) {
lock.Lock();
- bool ret = _ms_dispatch(m);
+ _ms_dispatch(m);
lock.Unlock();
- return ret;
+ return true;
}
// dissociate message handling from session and connection logic
- bool dispatch(MonSession *s, Message *m, const bool src_is_mon);
+ void dispatch(MonSession *s, Message *m, const bool src_is_mon);
//mon_caps is used for un-connected messages from monitors
MonCap * mon_caps;
bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer, bool force_new);