Skip to content

Commit b102608

Browse files
Merge pull request #4 from binarin/rabbitmq-common-3
Initialize PRNG with unique data
2 parents a9765d7 + b3d21a3 commit b102608

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/rabbit_nodes.erl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,19 @@ cluster_name_default() ->
202202
set_cluster_name(Name) ->
203203
rabbit_runtime_parameters:set_global(cluster_name, Name).
204204

205+
random(N) ->
206+
case get(random_seed) of
207+
undefined ->
208+
random:seed(erlang:phash2([node()]),
209+
time_compat:monotonic_time(),
210+
time_compat:unique_integer());
211+
_ -> ok
212+
end,
213+
random:uniform(N).
214+
205215
ensure_epmd() ->
206216
{ok, Prog} = init:get_argument(progname),
207-
ID = random:uniform(1000000000),
217+
ID = random(1000000000),
208218
Port = open_port(
209219
{spawn_executable, os:find_executable(Prog)},
210220
[{args, ["-sname", rabbit_misc:format("epmd-starter-~b", [ID]),

0 commit comments

Comments
 (0)