From: Kefu Chai Date: Tue, 2 Jun 2015 04:22:26 +0000 (+0800) Subject: mon: remove unnecessary error handling X-Git-Tag: v9.0.2~21^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=16e8e2cc82a90c49cd8aa3d0e3acc4694ba659a0;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 --- 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 7dc6c92df8d..3d00edd99c5 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -248,8 +248,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 74ba6a11211..ab809babc70 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3407,12 +3407,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); @@ -3420,11 +3419,7 @@ void Monitor::_ms_dispatch(Message *m) } dispatch(s, m, src_is_mon); - - if (s) { - s->put(); - } - + s->put(); return; }