Skip to content

Commit

Permalink
Merge pull request #1071 from erlang-ls/1070-fix-distribution-when-no…
Browse files Browse the repository at this point in the history
…-cookie-is-specified

[#1070] Only set the cookie if the provided one is a valid one
  • Loading branch information
robertoaloi authored Aug 11, 2021
2 parents 469d8e9 + 799bd5d commit c42f6dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/els_core/src/els_distribution_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ start_distribution(Name) ->
NameType = els_config_runtime:get_name_type(),
start_distribution(Name, RemoteNode, Cookie, NameType).

-spec start_distribution(atom(), atom(), atom(),
shortnames | longnames) -> any().
-spec start_distribution(atom(), atom(), atom(), shortnames | longnames) -> ok.
start_distribution(Name, RemoteNode, Cookie, NameType) ->
?LOG_INFO("Enable distribution [name=~p]", [Name]),
case net_kernel:start([Name, NameType]) of
{ok, _Pid} ->
erlang:set_cookie(RemoteNode, Cookie),
case Cookie of
nocookie ->
ok;
CustomCookie ->
erlang:set_cookie(RemoteNode, CustomCookie)
end,
?LOG_INFO("Distribution enabled [name=~p]", [Name]);
{error, {already_started, _Pid}} ->
?LOG_INFO("Distribution already enabled [name=~p]", [Name]);
Expand Down

0 comments on commit c42f6dd

Please sign in to comment.