From 39f34596b0ec6f769f507e2b372204f8551f7ee0 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 2 Jun 2015 12:22:26 +0800 Subject: [PATCH] mon: remove unnecessary error handling msg.get_session() should always return a non-zero pointer in Monitor.dispatch() Signed-off-by: Kefu Chai (cherry picked from commit 16e8e2cc82a90c49cd8aa3d0e3acc4694ba659a0) --- src/include/interval_set.h | 1 + src/mon/MDSMonitor.cc | 3 +-- src/mon/Monitor.cc | 15 +++++---------- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/include/interval_set.h b/src/include/interval_set.h index 7affb87ab7d71..9a7d2f2e104a6 100644 --- a/src/include/interval_set.h +++ b/src/include/interval_set.h @@ -371,6 +371,7 @@ class interval_set { void erase(iterator &i) { _size -= i.get_len(); + assert(_size >= 0); m.erase(i._iter); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index a9044ae242243..fc21436101609 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -246,8 +246,7 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m) // check privileges, ignore if fails MonSession *session = m->get_session(); - if (!session) - goto out; + assert(session); if (!session->is_capable("mds", MON_CAP_X)) { dout(0) << "preprocess_beacon got MMDSBeacon from entity with insufficient privileges " << session->caps << dendl; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 70cb7981cb6d3..db7c9f3a87a66 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3361,12 +3361,11 @@ void Monitor::_ms_dispatch(Message *m) dout(20) << "ms_dispatch existing session " << s << " for " << s->inst << dendl; } - if (s) { - if (s->auth_handler) { - s->entity_name = s->auth_handler->get_entity_name(); - } - dout(20) << " caps " << s->caps.get_str() << dendl; + assert(s); + if (s->auth_handler) { + s->entity_name = s->auth_handler->get_entity_name(); } + dout(20) << " caps " << s->caps.get_str() << dendl; if (is_synchronizing() && !src_is_mon) { waitlist_or_zap_client(m); @@ -3374,11 +3373,7 @@ void Monitor::_ms_dispatch(Message *m) } dispatch(s, m, src_is_mon); - - if (s) { - s->put(); - } - + s->put(); return; } -- 2.39.5