summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-04-30 17:12:05 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-04-30 17:12:05 +0100
commita3c165c9e2fd84d2d9d984dc1ed8dd58a218a5af (patch)
tree991716ea18ad9767f22bdb3c0be0f3c321a2a052
parentdee0a872f6d8cdf280cd48847484227a6a59c5ad (diff)
downloadceph-a3c165c9e2fd84d2d9d984dc1ed8dd58a218a5af.tar.gz
mon: Monitor: fix bug on _pick_random_mon() that would choose an invalid rank
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r--src/mon/Monitor.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index ea1f07a1231..077c9e99bd1 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -1048,6 +1048,8 @@ int Monitor::_pick_random_mon(int other)
return 0;
int max = monmap->size();
+ if (other >= 0)
+ max--;
int n = sync_rng() % max;
if (other >= 0 && n >= other)
n++;