]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Replace UFS use of random with C++11 feature
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Feb 2015 06:26:06 +0000 (22:26 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 8 Feb 2015 06:26:06 +0000 (22:26 -0800)
src/fs/ufs/UFSSwapDir.cc

index d9fa01fc96504b37b5ab4de727a485834b2d2502..75db77f99bf9f64763b97c7535a90e4557d56886 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <cerrno>
 #include <cmath>
+#include <random>
 #if HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
@@ -1042,7 +1043,9 @@ Fs::Ufs::UFSSwapDir::CleanEvent(void *)
          * value.  j equals the total number of UFS level 2
          * swap directories
          */
-        swap_index = (int) (squid_random() % j);
+        std::mt19937 mt(static_cast<uint32_t>(getCurrentTime() & 0xFFFFFFFF));
+        std::uniform_int_distribution<> dist(0, j);
+        swap_index = dist(mt);
     }
 
     /* if the rebuild is finished, start cleaning directories. */