Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
erts: -sname undefined now implies -dist_listen false
Also added documentation for -[s]name undefined.
  • Loading branch information
garazdawi committed Apr 17, 2020
1 parent 3a8c743 commit 61b1ad3
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 25 deletions.
51 changes: 38 additions & 13 deletions erts/doc/src/erl_cmd.xml
Expand Up @@ -373,7 +373,7 @@
modules, as conventionally happens in OTP releases. See
<seeerl marker="kernel:code"><c>code(3)</c></seeerl></p>.
</item>
<tag><c><![CDATA[-name Name]]></c></tag>
<tag><marker id="name"/><c><![CDATA[-name Name]]></c></tag>
<item>
<p>Makes the Erlang runtime system into a distributed node.
This flag invokes all network servers necessary for a node to
Expand All @@ -386,6 +386,31 @@
<c><![CDATA[Host]]></c> is the fully qualified host name of the
current host. For short names, use flag <c><![CDATA[-sname]]></c>
instead.</p>
<p>If <c>Name</c> is set to <em><c>undefined</c></em> the node will
be started in a special mode optimized to be the temporary client
of another node. When enabled the node will request a
<seeguide marker="erl_dist_protocol#DFLAG_NAME_ME">dynamic
node name</seeguide> from the first node it connects to. In addition
these distribution settings will be set:
</p>
<pre><seeapp marker="kernel:kernel_app#dist_listen">-dist_listen false</seeapp> <seecom marker="#hidden">-hidden</seecom> <seeapp marker="kernel:kernel_app#dist_auto_connect">-dist_auto_connect never</seeapp></pre>
<p>Because <c>-dist_auto_connect</c> is set to <c>never</c>, the system will have
to manually call <seemfa marker="kernel:net_kernel#connect_node/1">
<c>net_kernel:connect_node/1</c></seemfa> in order to start the distribution.
If the distribution channel is closed, when a node uses a dynamic
node name, the node will stop the distribution and a new call to
<seemfa marker="kernel:net_kernel#connect_node/1">
<c>net_kernel:connect_node/1</c></seemfa> has to be made. Note that the node
name may change if the distribution is dropped and then set up again.
</p>
<note>
<p>
The <em>dynamic node name</em> feature is supported from
OTP 23. Both the temporary client node and the first
connected peer node (supplying the dynamic node name) must
be at least OTP 23 for it to work.
</p>
</note>
<warning>
<p>
Starting a distributed node without also specifying
Expand Down Expand Up @@ -453,7 +478,7 @@
<tag><c>inet_tls</c></tag>
<item>Distribution over TLS/SSL, See the
<seeguide marker="ssl:ssl_distribution">
Using SSL for Erlang Distribution</seeguide> User's Guide
Using SSL for Erlang Distribution</seeguide> User&apos;s Guide
for details on how to setup a secure distributed node.
</item>
<tag><c>inet6_tcp</c></tag>
Expand Down Expand Up @@ -514,9 +539,9 @@
<tag><c><![CDATA[-sname Name]]></c></tag>
<item>
<p>Makes the Erlang runtime system into a distributed node, similar to
<c><![CDATA[-name]]></c>, but the host name portion of the node
name <c><![CDATA[Name@Host]]></c> will be the short name, not fully
qualified.</p>
<seecom marker="#name"><c><![CDATA[-name]]></c></seecom>, but the host
name portion of the node name <c><![CDATA[Name@Host]]></c> will be the
short name, not fully qualified.</p>
<p>This is sometimes the only way to run distributed Erlang if
the Domain Name System (DNS) is not running. No communication can
exist between nodes running with flag <c><![CDATA[-sname]]></c>
Expand Down Expand Up @@ -691,12 +716,12 @@
code points &gt; 255.</p>
<p>For more information about Unicode filenames, see section
<seeguide marker="stdlib:unicode_usage#unicode_file_names">Unicode
Filenames</seeguide> in the STDLIB User's Guide. Notice that
Filenames</seeguide> in the STDLIB User&apos;s Guide. Notice that
this value also applies to command-line parameters and environment
variables (see section <seeguide
marker="stdlib:unicode_usage#unicode_in_environment_and_parameters">
Unicode in Environment and Parameters</seeguide> in the STDLIB
User's Guide).</p>
User&apos;s Guide).</p>
</item>
<tag><c><![CDATA[+fnu[{w|i|e}]]]></c></tag>
<item>
Expand Down Expand Up @@ -727,12 +752,12 @@
points to an invalid filename.</p>
<p>For more information about Unicode filenames, see section
<seeguide marker="stdlib:unicode_usage#unicode_file_names">Unicode
Filenames</seeguide> in the STDLIB User's Guide. Notice that
Filenames</seeguide> in the STDLIB User&apos;s Guide. Notice that
this value also applies to command-line parameters and environment
variables (see section <seeguide
marker="stdlib:unicode_usage#unicode_in_environment_and_parameters">
Unicode in Environment and Parameters</seeguide> in the STDLIB
User's Guide).</p>
User&apos;s Guide).</p>
</item>
<tag><c><![CDATA[+fna[{w|i|e}]]]></c></tag>
<item>
Expand All @@ -748,12 +773,12 @@
selected, then <c>w</c>, <c>i</c>, or <c>e</c> have no effect.</p>
<p>For more information about Unicode filenames, see section
<seeguide marker="stdlib:unicode_usage#unicode_file_names">Unicode
Filenames</seeguide> in the STDLIB User's Guide. Notice that
Filenames</seeguide> in the STDLIB User&apos;s Guide. Notice that
this value also applies to command-line parameters and environment
variables (see section <seeguide
marker="stdlib:unicode_usage#unicode_in_environment_and_parameters">
Unicode in Environment and Parameters</seeguide> in the STDLIB
User's Guide).</p>
User&apos;s Guide).</p>
</item>
<tag><c><![CDATA[+hms Size]]></c></tag>
<item>
Expand Down Expand Up @@ -1115,7 +1140,7 @@
</item>
<tag><c>ts</c></tag>
<item><c>thread_spread</c> - Thread refers to hardware threads
(such as Intel's hyper-threads). Schedulers with low scheduler
(such as Intel&apos;s hyper-threads). Schedulers with low scheduler
identifiers, are bound to the first hardware thread of
each core, then schedulers with higher scheduler identifiers
are bound to the second hardware thread of each core,and so on.
Expand Down Expand Up @@ -1731,7 +1756,7 @@
<tag>The <c>.erlang</c> startup file</tag>
<item>
<p>When Erlang/OTP is started, the system searches for a file named
<c>.erlang</c> in the user's home directory.</p>
<c>.erlang</c> in the user&apos;s home directory.</p>
<p>If an <c>.erlang</c> file is found, it is assumed to contain valid
Erlang expressions. These expressions are evaluated as if they were
input to the shell.</p>
Expand Down
4 changes: 2 additions & 2 deletions lib/kernel/doc/src/kernel_app.xml
Expand Up @@ -134,7 +134,7 @@
<p>The parameter is described in
<seemfa marker="application#load/2"><c>application:load/2</c></seemfa>.</p>
</item>
<tag><c>dist_auto_connect = Value</c></tag>
<tag><marker id="dist_auto_connect"/><c>dist_auto_connect = Value</c></tag>
<item>
<p>Specifies when nodes are automatically connected. If
this parameter is not specified, a node is always
Expand All @@ -152,7 +152,7 @@
<seeerl marker="net_kernel"><c>net_kernel(3)</c></seeerl>.</p></item>
</taglist>
</item>
<tag><c>dist_listen = boolean()</c></tag>
<tag><marker id="dist_listen"/><c>dist_listen = boolean()</c></tag>
<item>
<p>Specifies whether this node should be listening for incoming
distribution connections. Using this option implies that the node
Expand Down
24 changes: 16 additions & 8 deletions lib/kernel/src/net_kernel.erl
Expand Up @@ -1679,14 +1679,18 @@ epmd_module() ->
%% dist_listen() -> whether the erlang distribution should listen for connections
%%
dist_listen() ->
case init:get_argument(dist_listen) of
{ok,[[DoListen]]} ->
list_to_atom(DoListen) =/= false;
_ ->
true
case persistent_term:get(net_kernel, undefined) of
dynamic_node_name ->
false;
_ ->
case init:get_argument(dist_listen) of
{ok,[[DoListen]]} ->
list_to_atom(DoListen) =/= false;
_ ->
true
end
end.


%%
%% Start all protocols
%%
Expand Down Expand Up @@ -1761,8 +1765,12 @@ wrap_creation(Cr) ->


start_protos_listen(Node, Ps, CleanHalt) ->
{Name, "@"++Host} = split_node(Node),
start_protos_listen(list_to_atom(Name), Host, Node, Ps, [], CleanHalt).
case split_node(Node) of
{"undefined", _} ->
start_protos_no_listen(Node, Ps, [], CleanHalt);
{Name, "@"++Host} ->
start_protos_listen(list_to_atom(Name), Host, Node, Ps, [], CleanHalt)
end.
start_protos_listen(Name, Host, Node, [Proto | Ps], Ls, CleanHalt) ->
Mod = list_to_atom(Proto ++ "_dist"),
try try Mod:listen(Name,Host)
Expand Down
4 changes: 2 additions & 2 deletions lib/stdlib/doc/src/shell.xml
Expand Up @@ -740,8 +740,8 @@ q - quit erlang

<p>If you want an Erlang node to have a remote job active from the start
(rather than the default local job), start Erlang with flag
<c>-remsh</c>, for example,
<c>erl -sname this_node -remsh other_node@other_host</c></p>
<seecom marker="erts:erl#remsh"><c>-remsh</c></seecom>, for example,
<c>erl -remsh other_node@other_host</c></p>
</section>

<section>
Expand Down

0 comments on commit 61b1ad3

Please sign in to comment.