aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/erl_epmd.erl
diff options
context:
space:
mode:
authorKostis Sagonas <[email protected]>2010-03-05 09:05:52 +0100
committerBjörn Gustavsson <[email protected]>2010-03-07 13:26:34 +0100
commitda70b2b0eca09f572e3275240ba60f1da6b679c4 (patch)
tree234ff94e9f9e0bd6c85c4e6f51cf2acd644903bd /lib/kernel/src/erl_epmd.erl
parent02112d8dba5b40cd0adb7ecb2b2ed4340594369f (diff)
downloadotp-da70b2b0eca09f572e3275240ba60f1da6b679c4.tar.gz
otp-da70b2b0eca09f572e3275240ba60f1da6b679c4.tar.bz2
otp-da70b2b0eca09f572e3275240ba60f1da6b679c4.zip
kernel: Add types and specs
Diffstat (limited to 'lib/kernel/src/erl_epmd.erl')
-rw-r--r--lib/kernel/src/erl_epmd.erl16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl
index e4b371836b..c2c796c1f7 100644
--- a/lib/kernel/src/erl_epmd.erl
+++ b/lib/kernel/src/erl_epmd.erl
@@ -40,6 +40,7 @@
-import(lists, [reverse/1]).
-record(state, {socket, port_no = -1, name = ""}).
+-type state() :: #state{}.
-include("inet_int.hrl").
-include("erl_epmd.hrl").
@@ -111,11 +112,18 @@ register_node(Name, PortNo) ->
%%% Callback functions from gen_server
%%%----------------------------------------------------------------------
+-spec init(_) -> {'ok', state()}.
+
init(_) ->
{ok, #state{socket = -1}}.
%%----------------------------------------------------------------------
+-type calls() :: 'client_info_req' | 'stop' | {'register', term(), term()}.
+
+-spec handle_call(calls(), term(), state()) ->
+ {'reply', term(), state()} | {'stop', 'shutdown', 'ok', state()}.
+
handle_call({register, Name, PortNo}, _From, State) ->
case State#state.socket of
P when P < 0 ->
@@ -141,11 +149,15 @@ handle_call(stop, _From, State) ->
%%----------------------------------------------------------------------
+-spec handle_cast(term(), state()) -> {'noreply', state()}.
+
handle_cast(_, State) ->
{noreply, State}.
%%----------------------------------------------------------------------
+-spec handle_info(term(), state()) -> {'noreply', state()}.
+
handle_info({tcp_closed, Socket}, State) when State#state.socket =:= Socket ->
{noreply, State#state{socket = -1}};
handle_info(_, State) ->
@@ -153,6 +165,8 @@ handle_info(_, State) ->
%%----------------------------------------------------------------------
+-spec terminate(term(), state()) -> 'ok'.
+
terminate(_, #state{socket = Socket}) when Socket > 0 ->
close(Socket),
ok;
@@ -161,6 +175,8 @@ terminate(_, _) ->
%%----------------------------------------------------------------------
+-spec code_change(term(), state(), term()) -> {'ok', state()}.
+
code_change(_OldVsn, State, _Extra) ->
{ok, State}.