aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/inet_db.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/inet_db.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/inet_db.erl')
-rw-r--r--lib/kernel/src/inet_db.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl
index a05b380855..ec95620cc0 100644
--- a/lib/kernel/src/inet_db.erl
+++ b/lib/kernel/src/inet_db.erl
@@ -88,6 +88,7 @@
hosts_file_byaddr, %% hosts table from system file
cache_timer %% timer reference for refresh
}).
+-type state() :: #state{}.
-include("inet.hrl").
-include("inet_int.hrl").
@@ -844,6 +845,9 @@ lookup_socket(Socket) when is_port(Socket) ->
%% node_auth Ls - Default authenication
%% node_crypt Ls - Default encryption
%%
+
+-spec init([]) -> {'ok', state()}.
+
init([]) ->
process_flag(trap_exit, true),
Db = ets:new(inet_db, [public, named_table]),
@@ -897,6 +901,10 @@ reset_db(Db) ->
%% {stop, Reason, Reply, State} | (terminate/2 is called)
%% {stop, Reason, Reply, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+
+-spec handle_call(term(), {pid(), term()}, state()) ->
+ {'reply', term(), state()} | {'stop', 'normal', 'ok', state()}.
+
handle_call(Request, From, #state{db=Db}=State) ->
case Request of
{load_hosts_file,IPNmAs} when is_list(IPNmAs) ->
@@ -1145,6 +1153,9 @@ handle_call(Request, From, #state{db=Db}=State) ->
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+
+-spec handle_cast(term(), state()) -> {'noreply', state()}.
+
handle_cast(_Msg, State) ->
{noreply, State}.
@@ -1154,6 +1165,9 @@ handle_cast(_Msg, State) ->
%% {noreply, State, Timeout} |
%% {stop, Reason, State} (terminate/2 is called)
%%----------------------------------------------------------------------
+
+-spec handle_info(term(), state()) -> {'noreply', state()}.
+
handle_info(refresh_timeout, State) ->
do_refresh_cache(State#state.cache),
{noreply, State#state{cache_timer = init_timer()}};
@@ -1166,6 +1180,9 @@ handle_info(_Info, State) ->
%% Purpose: Shutdown the server
%% Returns: any (ignored by gen_server)
%%----------------------------------------------------------------------
+
+-spec terminate(term(), state()) -> 'ok'.
+
terminate(_Reason, State) ->
stop_timer(State#state.cache_timer),
ok.