]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: prevent new sessions during shutdown 44543/head
authorSage Weil <sage@newdream.net>
Thu, 16 Dec 2021 15:24:46 +0000 (10:24 -0500)
committerCory Snyder <csnyder@iland.com>
Tue, 11 Jan 2022 20:29:21 +0000 (15:29 -0500)
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 <sage@newdream.net>
(cherry picked from commit c98b268847a1b79dbd1693f1c5ba120f6fc05855)

src/mon/Monitor.cc

index 3f2e2dc036663ac1ca1e81bf0d7a001127c51a42..ef20fb54a67aaaccd924ef0fb2b4235566418aaf 100644 (file)
@@ -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);
   }
 }