From: Sage Weil Date: Tue, 21 Jan 2020 21:09:01 +0000 (-0600) Subject: mon/Session: only index osd ids >= 0 X-Git-Tag: v14.2.8~20^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F32908%2Fhead;p=ceph.git mon/Session: only index osd ids >= 0 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 (cherry picked from commit d6f0642b82c5a1caa37b839bc8380aeb0c532143) Conflicts: src/mon/Session.h --- diff --git a/src/mon/Session.h b/src/mon/Session.h index fba33381f75..b6d176f50cf 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -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::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(s->name.num(), s)); } if (s->con_features) {