]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Session: only index osd ids >= 0 32908/head
authorSage Weil <sage@redhat.com>
Tue, 21 Jan 2020 21:09:01 +0000 (15:09 -0600)
committerNathan Cutler <ncutler@suse.com>
Mon, 27 Jan 2020 16:01:47 +0000 (17:01 +0100)
This ensures that get_random_osd_session behaves when it does

    int n = by_osd.rbegin()->first + 1;
    int r = rand() % n;

Fixes: https://tracker.ceph.com/issues/43552
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit d6f0642b82c5a1caa37b839bc8380aeb0c532143)

Conflicts:
src/mon/Session.h

src/mon/Session.h

index fba33381f75e3e53c808b6038ad708cf8716c4bd..b6d176f50cfdf6f76bc4f8185bb029e6bd1944f2 100644 (file)
@@ -134,7 +134,8 @@ struct MonSessionMap {
     }
     s->sub_map.clear();
     s->item.remove_myself();
-    if (s->name.is_osd()) {
+    if (s->name.is_osd() &&
+       s->name.num() >= 0) {
       for (multimap<int,MonSession*>::iterator p = by_osd.find(s->name.num());
           p->first == s->name.num();
           ++p)
@@ -163,7 +164,8 @@ struct MonSessionMap {
   void add_session(MonSession *s) {
     sessions.push_back(&s->item);
     s->get();
-    if (s->name.is_osd()) {
+    if (s->name.is_osd() &&
+       s->name.num() >= 0) {
       by_osd.insert(pair<int,MonSession*>(s->name.num(), s));
     }
     if (s->con_features) {