From: Sage Weil Date: Thu, 16 Dec 2021 15:24:46 +0000 (-0500) Subject: mon: prevent new sessions during shutdown X-Git-Tag: v17.1.0~211^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c98b268847a1b79dbd1693f1c5ba120f6fc05855;p=ceph.git mon: prevent new sessions during shutdown From shutdown() we set STATE_SHUTDOWN and then call remove_all_sessions(). ms_handle_accept() is the only caller of add_session, so verifying that we aren't shutting down (while under the session_map_lock) is sufficient to prevent any new sessions from being added. Fixes: https://tracker.ceph.com/issues/39150 Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index b1271153efd4b..e8856a5d120f6 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6443,12 +6443,17 @@ void Monitor::ms_handle_accept(Connection *con) dout(10) << __func__ << " con " << con << " session " << s << " already on list" << dendl; } else { + std::lock_guard l(session_map_lock); + if (state == STATE_SHUTDOWN) { + dout(10) << __func__ << " ignoring new con " << con << " (shutdown)" << dendl; + con->mark_down(); + return; + } dout(10) << __func__ << " con " << con << " session " << s << " registering session for " << con->get_peer_addrs() << dendl; s->_ident(entity_name_t(con->get_peer_type(), con->get_peer_id()), con->get_peer_addrs()); - std::lock_guard l(session_map_lock); session_map.add_session(s); } }