diff options
author | Sverker Eriksson <[email protected]> | 2015-11-10 15:43:15 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2015-11-10 15:43:15 +0100 |
commit | 949de78331b9c4ecb9c628bb651cecb113790e2e (patch) | |
tree | 108bbaeb677a9f0445ca5580e2d6034be8f58161 /erts/emulator/test | |
parent | 1eeb980a3591b51f12363543b2ac9b0260ebd870 (diff) | |
download | otp-949de78331b9c4ecb9c628bb651cecb113790e2e.tar.gz otp-949de78331b9c4ecb9c628bb651cecb113790e2e.tar.bz2 otp-949de78331b9c4ecb9c628bb651cecb113790e2e.zip |
erts: Fix bug in setnode/2
that could lead strange things to happen when renaming a node with
a name that already exist in node and dist tables.
Problem:
erts_set_this_node() is a bit brutal and does not handle the case
when an old remote node name is reused as the new local node name.
Solution:
Treat erts_this_node and erts_this_dist_entry as all the others
with correct reference counting.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/distribution_SUITE_data/run.erl | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/erts/emulator/test/distribution_SUITE_data/run.erl b/erts/emulator/test/distribution_SUITE_data/run.erl index f5169e160c..d5ed139369 100644 --- a/erts/emulator/test/distribution_SUITE_data/run.erl +++ b/erts/emulator/test/distribution_SUITE_data/run.erl @@ -30,16 +30,19 @@ from(H, [_ | T]) -> from(H, T); from(H, []) -> []. start() -> - net_kernel:start([fideridum,shortnames]), - {ok, Node} = slave:start(host(), heppel), - P = spawn(Node, a, b, []), - B1 = term_to_binary(P), - N1 = node(P), - ok = net_kernel:stop(), - N2 = node(P), - io:format("~w~n", [N1 == N2]), + Result = do_it(), + + %% Do GCs and node_and_dist_references + %% in an attempt to crash the VM (without OTP-13076 fix) + lists:foreach(fun(P) -> erlang:garbage_collect(P) end, + processes()), + erts_debug:set_internal_state(available_internal_state, true), + erts_debug:get_internal_state(node_and_dist_references), + + io:format("~w~n", [Result]), + if - N1 == N2 -> + Result -> init:stop(); true -> %% Make sure that the io:format/2 output is really written @@ -47,3 +50,29 @@ start() -> erlang:yield(), init:stop() end. + + +do_it() -> + {ok, _} = net_kernel:start([fideridum,shortnames]), + {ok, Node} = slave:start(host(), heppel), + P = spawn(Node, net_kernel, stop, []), + B1 = term_to_binary(P), + N1 = node(P), + ok = net_kernel:stop(), + N2 = node(P), + + %% OTP-13076 + %% Restart distribution with same node name as previous remote node + %% Repeat to wrap around creation + Result = lists:foldl(fun(_, Acc) -> + timer:sleep(2), % give net_kernel:stop() time to take effect :-( + {ok, _} = net_kernel:start([heppel,shortnames]), + N3 = node(P), + ok = net_kernel:stop(), + N4 = node(P), + Acc and (N3 =:= N1) and (N4 =:= N1) + end, + (N2 =:= N1), + lists:seq(1,3)), + + Result. |