Use phash2() and the new Time API as a random seed

References rabbitmq/rabbitmq-server#233.
This commit is contained in:
Jean-Sébastien Pédron 2015-08-05 15:13:18 +02:00
parent ff0781f71d
commit d05b8fd0d1
1 changed files with 3 additions and 1 deletions

View File

@ -71,7 +71,9 @@ remove_credentials(URI) ->
list_to_binary(amqp_uri:remove_credentials(binary_to_list(URI))).
to_params(Upstream = #upstream{uris = URIs}, XorQ) ->
random:seed(now()),
random:seed(erlang:phash2([node()]),
time_compat:monotonic_time(),
time_compat:unique_integer()),
URI = lists:nth(random:uniform(length(URIs)), URIs),
{ok, Params} = amqp_uri:parse(binary_to_list(URI), vhost(XorQ)),
XorQ1 = with_name(Upstream, vhost(Params), XorQ),