From 6b441f6ed94d8bf1de8d78b816dca87a3e79d36b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 16 Dec 2021 10:24:46 -0500 Subject: [PATCH] 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 (cherry picked from commit c98b268847a1b79dbd1693f1c5ba120f6fc05855) --- src/mon/Monitor.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3f2e2dc036663..ef20fb54a67aa 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -6450,12 +6450,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); } } -- 2.39.5