]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Monitor: fix bug on _pick_random_mon() that would choose an invalid rank
authorJoao Eduardo Luis <joao.luis@inktank.com>
Tue, 30 Apr 2013 16:12:05 +0000 (17:12 +0100)
committerSage Weil <sage@inktank.com>
Wed, 1 May 2013 17:45:59 +0000 (10:45 -0700)
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
src/mon/Monitor.cc

index 54e722ac948c67503936737ce41df12bb613ad96..b9afa4265d8fc7397cea662c4c3a9883b86371c2 100644 (file)
@@ -1071,6 +1071,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++;