]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: always use random number for msgr's nonce
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 2 Mar 2023 11:40:09 +0000 (11:40 +0000)
committeryite.gu <yitegu0@gmail.com>
Fri, 29 Sep 2023 23:59:07 +0000 (07:59 +0800)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 9654095bdbf7fc9815eace951e98290d2eeb451c)

src/crimson/osd/main_config_bootstrap_helpers.h

index 7c6131d172c08e42509b029fcf7f40dda18546e2..880e8007a02eaf6f3a407e62c4e2840228c14736 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "common/ceph_argparse.h"
 #include "include/expected.hpp"
+#include "include/random.h"
 
 namespace crimson::osd {
 
@@ -21,14 +22,7 @@ void usage(const char* prog);
 
 inline uint64_t get_nonce()
 {
-  if (auto pid = getpid(); pid == 1 || std::getenv("CEPH_USE_RANDOM_NONCE")) {
-    // we're running in a container; use a random number instead!
-    std::random_device rd;
-    std::default_random_engine rng{rd()};
-    return std::uniform_int_distribution<uint64_t>{}(rng);
-  } else {
-    return pid;
-  }
+  return ceph::util::generate_random_number<uint64_t>();
 }
 
 seastar::future<> populate_config_from_mon();