From: Kefu Chai Date: Tue, 2 Jun 2015 04:22:26 +0000 (+0800) Subject: mon: remove unnecessary error handling X-Git-Tag: v0.80.11~43^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=508332f53075a99295b9edb683ed343d8f59ca4f;p=ceph.git 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) Conflicts: src/mon/Monitor.cc Monitor::_ms_dispatch(Message *m) is bool in firefly --- diff --git a/src/include/interval_set.h b/src/include/interval_set.h index 7affb87ab7d..9a7d2f2e104 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 12755b7c455..342420fa8cd 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -208,8 +208,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 c39faad23e2..7be0f3e1dfb 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -2935,12 +2935,11 @@ bool 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); @@ -2948,11 +2947,7 @@ bool Monitor::_ms_dispatch(Message *m) } ret = dispatch(s, m, src_is_mon); - - if (s) { - s->put(); - } - + s->put(); return ret; }