aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/erl_boot_server.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-03-09 06:07:55 +0000
committerErlang/OTP <[email protected]>2010-03-09 06:07:55 +0000
commit36dab22b34d33e1fb8f22af9131d2b33aa97bbd5 (patch)
treeccd9f079beb8413f4b8889dae6827586c175da51 /lib/kernel/src/erl_boot_server.erl
parent02112d8dba5b40cd0adb7ecb2b2ed4340594369f (diff)
parent8fef4ffec7245102407ccf73afb5c5c4a42a4ee3 (diff)
downloadotp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.tar.gz
otp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.tar.bz2
otp-36dab22b34d33e1fb8f22af9131d2b33aa97bbd5.zip
Merge branch 'ks/types' into dev
* ks/types: file.hrl: Move out type declarations kernel: Add types and specs OTP-8494 ks/types
Diffstat (limited to 'lib/kernel/src/erl_boot_server.erl')
-rw-r--r--lib/kernel/src/erl_boot_server.erl26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/kernel/src/erl_boot_server.erl b/lib/kernel/src/erl_boot_server.erl
index 702b2feac9..c5a4305731 100644
--- a/lib/kernel/src/erl_boot_server.erl
+++ b/lib/kernel/src/erl_boot_server.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
%% A simple boot_server at a CP.
@@ -53,6 +53,7 @@
bootp :: pid(), %% boot process
prim_state %% state for efile code loader
}).
+-type state() :: #state{}.
-define(single_addr_mask, {255, 255, 255, 255}).
@@ -165,6 +166,8 @@ member_address(_, []) ->
%% call-back functions.
%% ------------------------------------------------------------
+-spec init([atom()]) -> {'ok', state()}.
+
init(Slaves) ->
{ok, U} = gen_udp:open(?EBOOT_PORT, []),
{ok, L} = gen_tcp:listen(0, [binary,{packet,4}]),
@@ -186,6 +189,9 @@ init(Slaves) ->
bootp = Pid
}}.
+-spec handle_call('which' | {'add',atom()} | {'delete',atom()}, _, state()) ->
+ {'reply', 'ok' | [atom()], state()}.
+
handle_call({add,Address}, _, S0) ->
Slaves = ordsets:add_element(Address, S0#state.slaves),
S0#state.bootp ! {slaves, Slaves},
@@ -197,9 +203,13 @@ handle_call({delete,Address}, _, S0) ->
handle_call(which, _, S0) ->
{reply, ordsets:to_list(S0#state.slaves), S0}.
+-spec handle_cast(term(), [atom()]) -> {'noreply', [atom()]}.
+
handle_cast(_, Slaves) ->
{noreply, Slaves}.
+-spec handle_info(term(), state()) -> {'noreply', state()}.
+
handle_info({udp, U, IP, Port, Data}, S0) ->
Token = ?EBOOT_REQUEST ++ S0#state.version,
Valid = member_address(IP, ordsets:to_list(S0#state.slaves)),
@@ -230,9 +240,13 @@ handle_info({udp, U, IP, Port, Data}, S0) ->
handle_info(_Info, S0) ->
{noreply,S0}.
+-spec terminate(term(), state()) -> 'ok'.
+
terminate(_Reason, _S0) ->
ok.
+-spec code_change(term(), state(), term()) -> {'ok', state()}.
+
code_change(_Vsn, State, _Extra) ->
{ok, State}.
@@ -242,6 +256,8 @@ code_change(_Vsn, State, _Extra) ->
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-spec boot_init(reference()) -> no_return().
+
boot_init(Tag) ->
receive
{Tag, Listen} ->