Skip to content

Commit 83c7a4b

Browse files
authored
Merge pull request basho#210 from basho/bjs/bugfix/cap_atom_usage
Fix RIAK-2702 by restricting possible atom usage to 1000
2 parents a3cae84 + 0917960 commit 83c7a4b

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

priv/base/nodetool

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,12 @@ nodename(Name) ->
189189
end.
190190

191191
append_node_suffix(Name, Suffix) ->
192+
random:seed(os:timestamp()),
192193
case string:tokens(Name, "@") of
193194
[Node, Host] ->
194-
list_to_atom(lists:concat([Node, Suffix, os:getpid(), "@", Host]));
195+
list_to_atom(lists:concat([Node, Suffix, random:uniform(1000), "@", Host]));
195196
[Node] ->
196-
list_to_atom(lists:concat([Node, Suffix, os:getpid()]))
197+
list_to_atom(lists:concat([Node, Suffix, random:uniform(1000)]))
197198
end.
198199

199200
chkconfig(File) ->

priv/base/runner

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ case "$1" in
306306
echo "Remote Shell: Use \"Ctrl-G q\" to quit."
307307
echo "q() or init:stop() will terminate the $SCRIPT node."
308308
shift
309+
RAND=$(($(($RANDOM % 1000)) + 1))
309310
NODE_NAME=${NAME_ARG#* }
310-
exec $ERTS_PATH/erl -name c_$$_$NODE_NAME -hidden -remsh $NODE_NAME $COOKIE_ARG $NET_TICKTIME_ARG
311+
exec $ERTS_PATH/erl -name c_$RAND_$NODE_NAME -hidden -remsh $NODE_NAME $COOKIE_ARG $NET_TICKTIME_ARG
311312
;;
312313

313314
console)
@@ -362,11 +363,11 @@ case "$1" in
362363
node_up_check
363364

364365
shift
365-
MYPID=$$
366+
RAND=$(($(($RANDOM % 1000)) + 1))
366367
NODE_NAME=${NAME_ARG#* }
367368
$ERTS_PATH/erl -noshell -noinput \
368369
-pa $RUNNER_PATCH_DIR \
369-
-hidden $NAME_PARAM np_etop$MYPID$NAME_HOST $COOKIE_ARG $NET_TICKTIME_ARG \
370+
-hidden $NAME_PARAM np_etop$RAND$NAME_HOST $COOKIE_ARG $NET_TICKTIME_ARG \
370371
-s etop -s erlang halt -output text \
371372
-node $NODE_NAME \
372373
$* -tracing off

0 commit comments

Comments
 (0)