]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: prevent new sessions during shutdown 44337/head
authorSage Weil <sage@newdream.net>
Thu, 16 Dec 2021 15:24:46 +0000 (10:24 -0500)
committerSage Weil <sage@newdream.net>
Thu, 16 Dec 2021 15:26:20 +0000 (10:26 -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>
src/mon/Monitor.cc

index b1271153efd4b265d50b37f80600d3734d54b163..e8856a5d120f64e7d3294356a38eb41396017097 100644 (file)
@@ -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);
   }
 }