]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make random shuffle comply with C++17 23533/head
authorWillem Jan Withagen <wjw@digiware.nl>
Fri, 10 Aug 2018 11:58:54 +0000 (13:58 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Mon, 13 Aug 2018 09:57:33 +0000 (11:57 +0200)
random_shuffle is depriacted in C++14 and removed in C++17 on FreeBSD
(As per the standard)

So this code does not compile on FreeBSD with Clang 6

Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/osd/OSDMap.cc

index 2fa444351f7278f9622bd645a8baa0abf5b0eb01..59cbcc78e94510dce2e3e461d2aa2fca95583c50 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "OSDMap.h"
 #include <algorithm>
+#include <random>
 #include "common/config.h"
 #include "common/errno.h"
 #include "common/Formatter.h"
@@ -5198,7 +5199,9 @@ void OSDMap::get_random_up_osds_by_subtree(int n,     // whoami
     return;
   vector<int> subtrees;
   crush->get_subtree_of_type(subtree_type, &subtrees);
-  std::random_shuffle(subtrees.begin(), subtrees.end());
+  std::random_device rd;
+  std::default_random_engine rng{rd()};
+  std::shuffle(subtrees.begin(), subtrees.end(), rng);
   for (auto s : subtrees) {
     if (limit <= 0)
       break;