aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-03-08 07:15:34 +0100
committerBjörn Gustavsson <[email protected]>2016-03-11 10:10:23 +0100
commitb5e35d8da2c83f176071730b0e7ce7daa7866f56 (patch)
tree78ba7cbcebda9db128e409006508d5a79c45b5a5 /lib
parent3159fa506c2ddf4cbca9887be798c67e32a981cc (diff)
downloadotp-b5e35d8da2c83f176071730b0e7ce7daa7866f56.tar.gz
otp-b5e35d8da2c83f176071730b0e7ce7daa7866f56.tar.bz2
otp-b5e35d8da2c83f176071730b0e7ce7daa7866f56.zip
Reorder and comment API functions
Move all functions meant to be called from other modules before the internal functions. Comment them to make it clearer what their purpose are.
Diffstat (limited to 'lib')
-rw-r--r--lib/kernel/src/erl_distribution.erl54
1 files changed, 33 insertions, 21 deletions
diff --git a/lib/kernel/src/erl_distribution.erl b/lib/kernel/src/erl_distribution.erl
index 99db7a8bf0..e97c9db81f 100644
--- a/lib/kernel/src/erl_distribution.erl
+++ b/lib/kernel/src/erl_distribution.erl
@@ -25,6 +25,8 @@
-define(DBG,erlang:display([?MODULE,?LINE])).
+%% Called during system start-up.
+
start_link() ->
case catch start_p() of
{ok,Args} ->
@@ -33,8 +35,38 @@ start_link() ->
ignore
end.
+%% Called from net_kernel:start/1 to start distribution after the
+%% system has already started.
+
+start(Args) ->
+ C = {net_sup_dynamic, {?MODULE,start_link,[Args]}, permanent,
+ 1000, supervisor, [erl_distribution]},
+ supervisor:start_child(kernel_sup, C).
+
+%% Stop distribution.
+
+stop() ->
+ case supervisor:terminate_child(kernel_sup, net_sup_dynamic) of
+ ok ->
+ supervisor:delete_child(kernel_sup, net_sup_dynamic);
+ Error ->
+ case whereis(net_sup) of
+ Pid when is_pid(Pid) ->
+ %% Dist. started through -sname | -name flags
+ {error, not_allowed};
+ _ ->
+ Error
+ end
+ end.
+
+%%%
+%%% Internal helper functions.
+%%%
+
+%% Helper start function.
+
start_link(Args) ->
- supervisor:start_link({local,net_sup},erl_distribution,Args).
+ supervisor:start_link({local,net_sup}, ?MODULE, Args).
init(NetArgs) ->
Epmd =
@@ -84,23 +116,3 @@ ticktime() ->
_ ->
[]
end.
-
-start(Args) ->
- C = {net_sup_dynamic, {erl_distribution, start_link, [Args]}, permanent,
- 1000, supervisor, [erl_distribution]},
- supervisor:start_child(kernel_sup, C).
-
-stop() ->
- case supervisor:terminate_child(kernel_sup, net_sup_dynamic) of
- ok ->
- supervisor:delete_child(kernel_sup, net_sup_dynamic);
- Error ->
- case whereis(net_sup) of
- Pid when is_pid(Pid) ->
- %% Dist. started through -sname | -name flags
- {error, not_allowed};
- _ ->
- Error
- end
- end.
-