]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: remove manual lock and RNG call
authorJesse Williamson <jwilliamson@suse.de>
Fri, 8 Sep 2017 22:48:54 +0000 (15:48 -0700)
committerJesse Williamson <jwilliamson@suse.de>
Fri, 8 Sep 2017 22:48:54 +0000 (15:48 -0700)
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
src/msg/Messenger.cc

index f97de0f14aa2a74ff92160432a4c10f4e357e222..3d9b57c12bc5f60364cbe09dd5b445a52c39703b 100644 (file)
@@ -1,12 +1,11 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#include <mutex>
-#include <random>
-
 #include <netdb.h>
 
 #include "include/types.h"
+#include "include/random.h"
+
 #include "Messenger.h"
 
 #include "msg/simple/SimpleMessenger.h"
@@ -30,14 +29,7 @@ Messenger *Messenger::create(CephContext *cct, const string &type,
 {
   int r = -1;
   if (type == "random") {
-    static std::random_device seed;
-    static std::default_random_engine random_engine(seed());
-
-    static std::mutex random_lock;
-    std::lock_guard<std::mutex> lock(random_lock);
-
-    std::uniform_int_distribution<> dis(0, 1);
-    r = dis(random_engine);
+    r = ceph::util::generate_random_number(0, 1);
   }
   if (r == 0 || type == "simple")
     return new SimpleMessenger(cct, name, std::move(lname), nonce);