]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: cast `whoami` to unsigned so it can be used as the seed for RNG 24659/head
authorKefu Chai <kchai@redhat.com>
Thu, 18 Oct 2018 10:29:49 +0000 (18:29 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 18 Oct 2018 10:29:50 +0000 (18:29 +0800)
default_random_engine's result_type is `unsigned int`, so we need to
pass an `unsigned int` as its seed.

Fixes: http://tracker.ceph.com/issues/26890
Signed-off-by: Kefu Chai <kchai@redhat.com>
Conflicts:
src/osd/OSD.cc: this breaks the build with clang. and in master
we are not using std::default_random_engine for setting the scrub
interval. so this change is not cherry-picked from master.

src/osd/OSD.cc

index 042097bb35e224710c9ad7185321545a61d04e8c..e2d1a6db7a5e7a0c2fd7cef40cc2457edd88cf40 100644 (file)
@@ -2055,7 +2055,7 @@ double OSD::get_tick_interval() const
 {
   // vary +/- 5% to avoid scrub scheduling livelocks
   constexpr auto delta = 0.05;
-  std::default_random_engine rng{whoami};
+  std::default_random_engine rng{static_cast<unsigned>(whoami)};
   return (OSD_TICK_INTERVAL *
           std::uniform_real_distribution<>{1.0 - delta, 1.0 + delta}(rng));
 }