Skip to content

Commit

Permalink
fix wrong compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
clonable-eden committed Dec 2, 2016
1 parent 6353dd5 commit 93703a5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/pooled_mongo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ stop() ->
-spec pool() -> poolid().
pool() ->
{ok, Pools} = application:get_env(pooled_mongo, pools),
Slot = case list_to_integer(erlang:system_info(otp_release)) of
V when V > 18 ->
% thanks: https://github.com/lasp-lang/rand_compat
Slot = case (code:which(rand) /= non_existing) of
true ->
rand:seed(exs1024),
rand:uniform(length(Pools));
_ ->
random:seed(erlang:timestamp()),
random:uniform(length(Pools))
end,
false ->
(fun random:seed/1)(erlang:timestamp()),
(fun random:uniform/1)(length(Pools))
end,
{Name, _, _} = lists:nth(Slot, Pools),
Name.

Expand Down

0 comments on commit 93703a5

Please sign in to comment.