aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2019-04-23 12:14:08 +0200
committerLukas Larsson <[email protected]>2019-04-23 13:49:21 +0200
commit4ffb28fa775daf7e157031654bcf7712cce6d0f1 (patch)
tree56840155a339aad7d29dc5bd8040d30710973930 /lib/kernel
parentd0d4f2be1ebfe8293a627531b65819e85482c1d9 (diff)
downloadotp-4ffb28fa775daf7e157031654bcf7712cce6d0f1.tar.gz
otp-4ffb28fa775daf7e157031654bcf7712cce6d0f1.tar.bz2
otp-4ffb28fa775daf7e157031654bcf7712cce6d0f1.zip
kernel: Multiple -sname or -name would be ignored
If 'erl -sname 1 -sname 2' is run the node is not started in distribution mode at all. This fix makes the last sname be used.
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/erl_distribution.erl6
-rw-r--r--lib/kernel/test/erl_distribution_SUITE.erl8
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/kernel/src/erl_distribution.erl b/lib/kernel/src/erl_distribution.erl
index 0bec78e938..cdb2d2f1f6 100644
--- a/lib/kernel/src/erl_distribution.erl
+++ b/lib/kernel/src/erl_distribution.erl
@@ -21,6 +21,8 @@
-behaviour(supervisor).
+-include_lib("kernel/include/logger.hrl").
+
-export([start_link/0,start_link/2,init/1,start/1,stop/0]).
-define(DBG,erlang:display([?MODULE,?LINE])).
@@ -83,6 +85,10 @@ do_start_link([{Arg,Flag}|T]) ->
case init:get_argument(Arg) of
{ok,[[Name]]} ->
start_link([list_to_atom(Name),Flag|ticktime()], true);
+ {ok,[[Name]|_Rest]} ->
+ ?LOG_WARNING("Multiple -~p given to erl, using the first, ~p",
+ [Arg, Name]),
+ start_link([list_to_atom(Name),Flag|ticktime()], true);
_ ->
do_start_link(T)
end;
diff --git a/lib/kernel/test/erl_distribution_SUITE.erl b/lib/kernel/test/erl_distribution_SUITE.erl
index 8dd4ef1987..c3a022df0a 100644
--- a/lib/kernel/test/erl_distribution_SUITE.erl
+++ b/lib/kernel/test/erl_distribution_SUITE.erl
@@ -205,6 +205,9 @@ nodenames(Config) when is_list(Config) ->
legal("a-1@b"),
legal("a_1@b"),
+ %% Test that giving two -sname works as it should
+ test_node("a_1@b", false, long_or_short() ++ "a_0@b"),
+
illegal("cdé@a"),
illegal("te欢st@a").
@@ -258,8 +261,11 @@ illegal(Name) ->
test_node(Name) ->
test_node(Name, false).
test_node(Name, Illigal) ->
+ test_node(Name, Illigal, "").
+test_node(Name, Illigal, ExtraArgs) ->
ProgName = ct:get_progname(),
- Command = ProgName ++ " -noinput " ++ long_or_short() ++ Name ++
+ Command = ProgName ++ " -noinput " ++ ExtraArgs ++
+ long_or_short() ++ Name ++
" -eval \"net_adm:ping('" ++ atom_to_list(node()) ++ "')\"" ++
case Illigal of
true ->