diff options
Diffstat (limited to 'lib/kernel/src')
51 files changed, 854 insertions, 444 deletions
diff --git a/lib/kernel/src/application.erl b/lib/kernel/src/application.erl index 4e8ba1b78a..c4bef5188a 100644 --- a/lib/kernel/src/application.erl +++ b/lib/kernel/src/application.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2013. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. 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 @@ -30,6 +30,8 @@ -export([get_application/0, get_application/1, info/0]). -export([start_type/0]). +-export_type([start_type/0]). + %%%----------------------------------------------------------------- -type start_type() :: 'normal' @@ -58,8 +60,7 @@ %%------------------------------------------------------------------ --callback start(StartType :: normal | {takeover, node()} | {failover, node()}, - StartArgs :: term()) -> +-callback start(StartType :: start_type(), StartArgs :: term()) -> {'ok', pid()} | {'ok', pid(), State :: term()} | {'error', Reason :: term()}. -callback stop(State :: term()) -> @@ -132,7 +133,7 @@ ensure_all_started(Application, Type) -> {ok, Started} -> {ok, lists:reverse(Started)}; {error, Reason, Started} -> - [stop(App) || App <- Started], + _ = [stop(App) || App <- Started], {error, Reason} end. @@ -285,16 +286,18 @@ info() -> set_env(Application, Key, Val) -> application_controller:set_env(Application, Key, Val). --spec set_env(Application, Par, Val, Timeout) -> 'ok' when +-spec set_env(Application, Par, Val, Opts) -> 'ok' when Application :: atom(), Par :: atom(), Val :: term(), - Timeout :: timeout(). + Opts :: [{timeout, timeout()} | {persistent, boolean()}]. set_env(Application, Key, Val, infinity) -> - application_controller:set_env(Application, Key, Val, infinity); + set_env(Application, Key, Val, [{timeout, infinity}]); set_env(Application, Key, Val, Timeout) when is_integer(Timeout), Timeout>=0 -> - application_controller:set_env(Application, Key, Val, Timeout). + set_env(Application, Key, Val, [{timeout, Timeout}]); +set_env(Application, Key, Val, Opts) when is_list(Opts) -> + application_controller:set_env(Application, Key, Val, Opts). -spec unset_env(Application, Par) -> 'ok' when Application :: atom(), @@ -303,15 +306,17 @@ set_env(Application, Key, Val, Timeout) when is_integer(Timeout), Timeout>=0 -> unset_env(Application, Key) -> application_controller:unset_env(Application, Key). --spec unset_env(Application, Par, Timeout) -> 'ok' when +-spec unset_env(Application, Par, Opts) -> 'ok' when Application :: atom(), Par :: atom(), - Timeout :: timeout(). + Opts :: [{timeout, timeout()} | {persistent, boolean()}]. unset_env(Application, Key, infinity) -> - application_controller:unset_env(Application, Key, infinity); + unset_env(Application, Key, [{timeout, infinity}]); unset_env(Application, Key, Timeout) when is_integer(Timeout), Timeout>=0 -> - application_controller:unset_env(Application, Key, Timeout). + unset_env(Application, Key, [{timeout, Timeout}]); +unset_env(Application, Key, Opts) when is_list(Opts) -> + application_controller:unset_env(Application, Key, Opts). -spec get_env(Par) -> 'undefined' | {'ok', Val} when Par :: atom(), diff --git a/lib/kernel/src/application_controller.erl b/lib/kernel/src/application_controller.erl index 9ed2c7a7d9..daad45b6c2 100644 --- a/lib/kernel/src/application_controller.erl +++ b/lib/kernel/src/application_controller.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2013. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. 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 @@ -461,14 +461,16 @@ permit_application(ApplName, Flag) -> set_env(AppName, Key, Val) -> - gen_server:call(?AC, {set_env, AppName, Key, Val}). -set_env(AppName, Key, Val, Timeout) -> - gen_server:call(?AC, {set_env, AppName, Key, Val}, Timeout). + gen_server:call(?AC, {set_env, AppName, Key, Val, []}). +set_env(AppName, Key, Val, Opts) -> + Timeout = proplists:get_value(timeout, Opts, 5000), + gen_server:call(?AC, {set_env, AppName, Key, Val, Opts}, Timeout). unset_env(AppName, Key) -> - gen_server:call(?AC, {unset_env, AppName, Key}). -unset_env(AppName, Key, Timeout) -> - gen_server:call(?AC, {unset_env, AppName, Key}, Timeout). + gen_server:call(?AC, {unset_env, AppName, Key, []}). +unset_env(AppName, Key, Opts) -> + Timeout = proplists:get_value(timeout, Opts, 5000), + gen_server:call(?AC, {unset_env, AppName, Key, Opts}, Timeout). %%%----------------------------------------------------------------- %%% call-back functions from gen_server @@ -488,7 +490,7 @@ init(Init, Kernel) -> %% called during start-up of any app. case check_conf_data(ConfData) of ok -> - ets:new(ac_tab, [set, public, named_table]), + _ = ets:new(ac_tab, [set, public, named_table]), S = #state{conf_data = ConfData}, {ok, KAppl} = make_appl(Kernel), case catch load(S, KAppl) of @@ -609,8 +611,8 @@ check_para([Else | _ParaList], AppName) -> | {'change_application_data', _, _} | {'permit_application', atom() | {'application',atom(),_},_} | {'start_application', _, _} - | {'unset_env', _, _} - | {'set_env', _, _, _}. + | {'unset_env', _, _, _} + | {'set_env', _, _, _, _}. -spec handle_call(calls(), {pid(), term()}, state()) -> {'noreply', state()} | {'reply', term(), state()}. @@ -827,12 +829,12 @@ handle_call({change_application_data, Applications, Config}, _From, S) -> {reply, Error, S}; {'EXIT', R} -> {reply, {error, R}, S}; - NewAppls -> + {NewAppls, NewConfig} -> lists:foreach(fun(Appl) -> ets:insert(ac_tab, {{loaded, Appl#appl.name}, Appl}) end, NewAppls), - {reply, ok, S#state{conf_data = Config}} + {reply, ok, S#state{conf_data = NewConfig}} end; handle_call(prep_config_change, _From, S) -> @@ -858,13 +860,25 @@ handle_call(which_applications, _From, S) -> end, S#state.running), {reply, Reply, S}; -handle_call({set_env, AppName, Key, Val}, _From, S) -> +handle_call({set_env, AppName, Key, Val, Opts}, _From, S) -> ets:insert(ac_tab, {{env, AppName, Key}, Val}), - {reply, ok, S}; + case proplists:get_value(persistent, Opts, false) of + true -> + Fun = fun(Env) -> lists:keystore(Key, 1, Env, {Key, Val}) end, + {reply, ok, S#state{conf_data = change_app_env(S#state.conf_data, AppName, Fun)}}; + false -> + {reply, ok, S} + end; -handle_call({unset_env, AppName, Key}, _From, S) -> +handle_call({unset_env, AppName, Key, Opts}, _From, S) -> ets:delete(ac_tab, {env, AppName, Key}), - {reply, ok, S}; + case proplists:get_value(persistent, Opts, false) of + true -> + Fun = fun(Env) -> lists:keydelete(Key, 1, Env) end, + {reply, ok, S#state{conf_data = change_app_env(S#state.conf_data, AppName, Fun)}}; + false -> + {reply, ok, S} + end; handle_call({control_application, AppName}, {Pid, _Tag}, S) -> Control = S#state.control, @@ -1536,18 +1550,19 @@ do_change_apps(Applications, Config, OldAppls) -> end, Errors), - map(fun(Appl) -> - AppName = Appl#appl.name, - case is_loaded_app(AppName, Applications) of - {true, Application} -> - do_change_appl(make_appl(Application), - Appl, SysConfig); + {map(fun(Appl) -> + AppName = Appl#appl.name, + case is_loaded_app(AppName, Applications) of + {true, Application} -> + do_change_appl(make_appl(Application), + Appl, SysConfig); - %% ignored removed apps - handled elsewhere - false -> - Appl - end - end, OldAppls). + %% ignored removed apps - handled elsewhere + false -> + Appl + end + end, OldAppls), + SysConfig}. is_loaded_app(AppName, [{application, AppName, App} | _]) -> {true, {application, AppName, App}}; @@ -1640,6 +1655,16 @@ merge_env([{App, AppEnv1} | T], Env2, Res) -> merge_env([], Env2, Res) -> Env2 ++ Res. +%% Changes the environment for the given application +%% If there is no application, an empty one is created +change_app_env(Env, App, Fun) -> + case get_env_key(App, Env) of + {value, AppEnv, RestEnv} -> + [{App, Fun(AppEnv)} | RestEnv]; + _ -> + [{App, Fun([])} | Env] + end. + %% Merges envs for an application. Env2 overrides Env1 merge_app_env(Env1, Env2) -> merge_app_env(Env1, Env2, []). @@ -1949,10 +1974,10 @@ test_change_apps(Apps, Conf) -> test_do_change_appl([], _, _) -> ok; test_do_change_appl([A|Apps], [], [R|Res]) -> - do_change_appl(R, #appl{name = A}, []), + _ = do_change_appl(R, #appl{name = A}, []), test_do_change_appl(Apps, [], Res); test_do_change_appl([A|Apps], [C|Conf], [R|Res]) -> - do_change_appl(R, #appl{name = A}, C), + _ = do_change_appl(R, #appl{name = A}, C), test_do_change_appl(Apps, Conf, Res). test_make_apps([], Res) -> diff --git a/lib/kernel/src/application_master.erl b/lib/kernel/src/application_master.erl index 3e636197bb..bc15b5a7de 100644 --- a/lib/kernel/src/application_master.erl +++ b/lib/kernel/src/application_master.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2013. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. 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 @@ -27,7 +27,7 @@ -include("application_master.hrl"). --record(state, {child, appl_data, children = [], procs = 0, gleader}). +-record(state, {child, appl_data, children = [], procs = 0, gleader, req=[]}). %%----------------------------------------------------------------- %% Func: start_link/1 @@ -125,7 +125,7 @@ init(Parent, Starter, ApplData, Type) -> State = #state{appl_data = ApplData, gleader = OldGleader}, case start_it(State, Type) of {ok, Pid} -> % apply(M,F,A) returned ok - set_timer(ApplData#appl_data.maxT), + ok = set_timer(ApplData#appl_data.maxT), unlink(Starter), proc_lib:init_ack(Starter, {ok,self()}), main_loop(Parent, State#state{child = Pid}); @@ -205,22 +205,25 @@ terminate_loop(Child, State) -> %%----------------------------------------------------------------- %% The Application Master is linked to *all* processes in the group -%% (application). +%% (application). %%----------------------------------------------------------------- handle_msg({get_child, Tag, From}, State) -> - From ! {Tag, get_child_i(State#state.child)}, - State; + get_child_i(State, Tag, From); handle_msg({stop, Tag, From}, State) -> catch terminate(normal, State), From ! {Tag, ok}, exit(normal); +handle_msg({child, Ref, GrandChild, Mod}, #state{req=Reqs0}=State) -> + {value, {_, Tag, From}, Reqs} = lists:keytake(Ref, 1, Reqs0), + From ! {Tag, {GrandChild, Mod}}, + State#state{req=Reqs}; handle_msg(_, State) -> State. - -terminate(Reason, State) -> - terminate_child(State#state.child, State), - kill_children(State#state.children), +terminate(Reason, State = #state{child=Child, children=Children, req=Reqs}) -> + _ = [From ! {Tag, error} || {_, Tag, From} <- Reqs], + terminate_child(Child, State), + kill_children(Children), exit(Reason). @@ -342,8 +345,8 @@ start_supervisor(Type, M, A) -> loop_it(Parent, Child, Mod, AppState) -> receive - {Parent, get_child} -> - Parent ! {self(), Child, Mod}, + {Parent, get_child, Ref} -> + Parent ! {child, Ref, Child, Mod}, loop_it(Parent, Child, Mod, AppState); {Parent, terminate} -> NewAppState = prep_stop(Mod, AppState), @@ -382,10 +385,15 @@ prep_stop(Mod, AppState) -> NewAppState end. -get_child_i(Child) -> - Child ! {self(), get_child}, - receive - {Child, GrandChild, Mod} -> {GrandChild, Mod} +get_child_i(#state{child=Child, req=Reqs}=State, Tag, From) -> + Ref = erlang:make_ref(), + case erlang:is_process_alive(Child) of + true -> + Child ! {self(), get_child, Ref}, + State#state{req=[{Ref, Tag, From}|Reqs]}; + false -> + From ! {Tag, error}, + State end. terminate_child_i(Child, State) -> @@ -418,4 +426,6 @@ kill_all_procs_1([], _, 0) -> ok; kill_all_procs_1([], _, _) -> kill_all_procs(). set_timer(infinity) -> ok; -set_timer(Time) -> timer:exit_after(Time, timeout). +set_timer(Time) -> + {ok, _} = timer:exit_after(Time, timeout), + ok. diff --git a/lib/kernel/src/auth.erl b/lib/kernel/src/auth.erl index 7d463103e3..eda35147d3 100644 --- a/lib/kernel/src/auth.erl +++ b/lib/kernel/src/auth.erl @@ -324,7 +324,7 @@ read_cookie(Name, Size) -> {ok, File} -> case file:read(File, Size) of {ok, List} -> - file:close(File), + ok = file:close(File), check_cookie(List, []); {error, Reason} -> make_error(Name, Reason) @@ -376,7 +376,7 @@ create_cookie(Name) -> case file:open(Name, [write, raw]) of {ok, File} -> R1 = file:write(File, Cookie), - file:close(File), + ok = file:close(File), R2 = file:raw_write_file_info(Name, make_info(Name)), case {R1, R2} of {ok, ok} -> diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl index 03fba96d4b..0eda558ed5 100644 --- a/lib/kernel/src/code.erl +++ b/lib/kernel/src/code.erl @@ -364,7 +364,7 @@ load_code_server_prerequisites() -> lists, os, unicode], - [M = M:module_info(module) || M <- Needed], + _ = [M = M:module_info(module) || M <- Needed], ok. do_stick_dirs() -> diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl index 5d74e8620b..fc7ac08699 100644 --- a/lib/kernel/src/code_server.erl +++ b/lib/kernel/src/code_server.erl @@ -153,7 +153,7 @@ loop(#state{supervisor=Supervisor}=State0) -> {code_call, Pid, Req} -> case handle_call(Req, {Pid, call}, State0) of {reply, Res, State} -> - reply(Pid, Res), + _ = reply(Pid, Res), loop(State); {noreply, State} -> loop(State); @@ -1410,45 +1410,236 @@ absname_vr([[X, $:]|Name], _, _AbsBase) -> do_purge(Mod0) -> Mod = to_atom(Mod0), case erlang:check_old_code(Mod) of - false -> false; - true -> do_purge(processes(), Mod, false) - end. - -do_purge([P|Ps], Mod, Purged) -> - case erlang:check_process_code(P, Mod) of + false -> + false; true -> - Ref = erlang:monitor(process, P), - exit(P, kill), - receive - {'DOWN',Ref,process,_Pid,_} -> ok + Res = check_proc_code(erlang:processes(), Mod, true), + try + erlang:purge_module(Mod) + catch + _:_ -> ignore end, - do_purge(Ps, Mod, true); - false -> - do_purge(Ps, Mod, Purged) - end; -do_purge([], Mod, Purged) -> - catch erlang:purge_module(Mod), - Purged. + Res + end. %% do_soft_purge(Module) %% Purge old code only if no procs remain that run old code. %% Return true in that case, false if procs remain (in this %% case old code is not purged) -do_soft_purge(Mod) -> +do_soft_purge(Mod0) -> + Mod = to_atom(Mod0), case erlang:check_old_code(Mod) of - false -> true; - true -> do_soft_purge(processes(), Mod) + false -> + true; + true -> + case check_proc_code(erlang:processes(), Mod, false) of + false -> + false; + true -> + try + erlang:purge_module(Mod) + catch + _:_ -> ignore + end, + true + end end. -do_soft_purge([P|Ps], Mod) -> - case erlang:check_process_code(P, Mod) of - true -> false; - false -> do_soft_purge(Ps, Mod) +%% +%% check_proc_code(Pids, Mod, Hard) - Send asynchronous +%% requests to all processes to perform a check_process_code +%% operation. Each process will check their own state and +%% reply with the result. If 'Hard' equals +%% - true, processes that refer 'Mod' will be killed. If +%% any processes were killed true is returned; otherwise, +%% false. +%% - false, and any processes refer 'Mod', false will +%% returned; otherwise, true. +%% +%% Requests will be sent to all processes identified by +%% Pids at once, but without allowing GC to be performed. +%% Check process code operations that are aborted due to +%% GC need, will be restarted allowing GC. However, only +%% ?MAX_CPC_GC_PROCS outstanding operation allowing GC at +%% a time will be allowed. This in order not to blow up +%% memory wise. +%% +%% We also only allow ?MAX_CPC_NO_OUTSTANDING_KILLS +%% outstanding kills. This both in order to avoid flooding +%% our message queue with 'DOWN' messages and limiting the +%% amount of memory used to keep references to all +%% outstanding kills. +%% + +%% We maybe should allow more than two outstanding +%% GC requests, but for now we play it safe... +-define(MAX_CPC_GC_PROCS, 2). +-define(MAX_CPC_NO_OUTSTANDING_KILLS, 10). + +-record(cpc_static, {hard, module, tag}). + +-record(cpc_kill, {outstanding = [], + no_outstanding = 0, + waiting = [], + killed = false}). + +check_proc_code(Pids, Mod, Hard) -> + Tag = erlang:make_ref(), + CpcS = #cpc_static{hard = Hard, + module = Mod, + tag = Tag}, + check_proc_code(CpcS, cpc_init(CpcS, Pids, 0), 0, [], #cpc_kill{}, true). + +check_proc_code(#cpc_static{hard = true}, 0, 0, [], + #cpc_kill{outstanding = [], waiting = [], killed = Killed}, + true) -> + %% No outstanding requests. We did a hard check, so result is whether or + %% not we killed any processes... + Killed; +check_proc_code(#cpc_static{hard = false}, 0, 0, [], _KillState, Success) -> + %% No outstanding requests and we did a soft check... + Success; +check_proc_code(#cpc_static{hard = false, tag = Tag} = CpcS, NoReq0, NoGcReq0, + [], _KillState, false) -> + %% Failed soft check; just cleanup the remaining replies corresponding + %% to the requests we've sent... + {NoReq1, NoGcReq1} = receive + {check_process_code, {Tag, _P, GC}, _Res} -> + case GC of + false -> {NoReq0-1, NoGcReq0}; + true -> {NoReq0, NoGcReq0-1} + end + end, + check_proc_code(CpcS, NoReq1, NoGcReq1, [], _KillState, false); +check_proc_code(#cpc_static{tag = Tag} = CpcS, NoReq0, NoGcReq0, NeedGC0, + KillState0, Success) -> + + %% Check if we should request a GC operation + {NoGcReq1, NeedGC1} = case NoGcReq0 < ?MAX_CPC_GC_PROCS of + GcOpAllowed when GcOpAllowed == false; + NeedGC0 == [] -> + {NoGcReq0, NeedGC0}; + _ -> + {NoGcReq0+1, cpc_request_gc(CpcS,NeedGC0)} + end, + + %% Wait for a cpc reply or 'DOWN' message + {NoReq1, NoGcReq2, Pid, Result, KillState1} = cpc_recv(Tag, + NoReq0, + NoGcReq1, + KillState0), + + %% Check the result of the reply + case Result of + aborted -> + %% Operation aborted due to the need to GC in order to + %% determine if the process is referring the module. + %% Schedule the operation for restart allowing GC... + check_proc_code(CpcS, NoReq1, NoGcReq2, [Pid|NeedGC1], KillState1, + Success); + false -> + %% Process not referring the module; done with this process... + check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1, KillState1, + Success); + true -> + %% Process referring the module... + case CpcS#cpc_static.hard of + false -> + %% ... and soft check. The whole operation failed so + %% no point continuing; clean up and fail... + check_proc_code(CpcS, NoReq1, NoGcReq2, [], KillState1, + false); + true -> + %% ... and hard check; schedule kill of it... + check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1, + cpc_sched_kill(Pid, KillState1), Success) + end; + 'DOWN' -> + %% Handled 'DOWN' message + check_proc_code(CpcS, NoReq1, NoGcReq2, NeedGC1, + KillState1, Success) + end. + +cpc_recv(Tag, NoReq, NoGcReq, #cpc_kill{outstanding = []} = KillState) -> + receive + {check_process_code, {Tag, Pid, GC}, Res} -> + cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState) end; -do_soft_purge([], Mod) -> - catch erlang:purge_module(Mod), - true. +cpc_recv(Tag, NoReq, NoGcReq, + #cpc_kill{outstanding = [R0, R1, R2, R3, R4 | _]} = KillState) -> + receive + {'DOWN', R, process, _, _} when R == R0; + R == R1; + R == R2; + R == R3; + R == R4 -> + cpc_handle_down(NoReq, NoGcReq, R, KillState); + {check_process_code, {Tag, Pid, GC}, Res} -> + cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState) + end; +cpc_recv(Tag, NoReq, NoGcReq, #cpc_kill{outstanding = [R|_]} = KillState) -> + receive + {'DOWN', R, process, _, _} -> + cpc_handle_down(NoReq, NoGcReq, R, KillState); + {check_process_code, {Tag, Pid, GC}, Res} -> + cpc_handle_cpc(NoReq, NoGcReq, GC, Pid, Res, KillState) + end. + +cpc_handle_down(NoReq, NoGcReq, R, #cpc_kill{outstanding = Rs, + no_outstanding = N} = KillState) -> + {NoReq, NoGcReq, undefined, 'DOWN', + cpc_sched_kill_waiting(KillState#cpc_kill{outstanding = cpc_list_rm(R, Rs), + no_outstanding = N-1})}. + +cpc_list_rm(R, [R|Rs]) -> + Rs; +cpc_list_rm(R0, [R1|Rs]) -> + [R1|cpc_list_rm(R0, Rs)]. + +cpc_handle_cpc(NoReq, NoGcReq, false, Pid, Res, KillState) -> + {NoReq-1, NoGcReq, Pid, Res, KillState}; +cpc_handle_cpc(NoReq, NoGcReq, true, Pid, Res, KillState) -> + {NoReq, NoGcReq-1, Pid, Res, KillState}. + +cpc_sched_kill_waiting(#cpc_kill{waiting = []} = KillState) -> + KillState; +cpc_sched_kill_waiting(#cpc_kill{outstanding = Rs, + no_outstanding = N, + waiting = [P|Ps]} = KillState) -> + R = erlang:monitor(process, P), + exit(P, kill), + KillState#cpc_kill{outstanding = [R|Rs], + no_outstanding = N+1, + waiting = Ps, + killed = true}. + +cpc_sched_kill(Pid, #cpc_kill{no_outstanding = N, waiting = Pids} = KillState) + when N >= ?MAX_CPC_NO_OUTSTANDING_KILLS -> + KillState#cpc_kill{waiting = [Pid|Pids]}; +cpc_sched_kill(Pid, + #cpc_kill{outstanding = Rs, no_outstanding = N} = KillState) -> + R = erlang:monitor(process, Pid), + exit(Pid, kill), + KillState#cpc_kill{outstanding = [R|Rs], + no_outstanding = N+1, + killed = true}. + +cpc_request(#cpc_static{tag = Tag, module = Mod}, Pid, AllowGc) -> + erlang:check_process_code(Pid, Mod, [{async, {Tag, Pid, AllowGc}}, + {allow_gc, AllowGc}]). + +cpc_request_gc(CpcS, [Pid|Pids]) -> + cpc_request(CpcS, Pid, true), + Pids. + +cpc_init(_CpcS, [], NoReqs) -> + NoReqs; +cpc_init(CpcS, [Pid|Pids], NoReqs) -> + cpc_request(CpcS, Pid, false), + cpc_init(CpcS, Pids, NoReqs+1). + +% end of check_proc_code() implementation. is_loaded(M, Db) -> case ets:lookup(Db, M) of @@ -1505,13 +1696,13 @@ finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db) -> erlang:finish_after_on_load(Mod, Keep), Res = case Keep of false -> - finish_on_load_report(Mod, OnLoadRes), + _ = finish_on_load_report(Mod, OnLoadRes), {error,on_load_failure}; true -> ets:insert(Db, {Mod,File}), {module,Mod} end, - [reply(Pid, Res) || Pid <- WaitingPids], + _ = [reply(Pid, Res) || Pid <- WaitingPids], ok. finish_on_load_report(_Mod, Atom) when is_atom(Atom) -> diff --git a/lib/kernel/src/disk_log.erl b/lib/kernel/src/disk_log.erl index c238eff12f..9a7726cfa0 100644 --- a/lib/kernel/src/disk_log.erl +++ b/lib/kernel/src/disk_log.erl @@ -1076,13 +1076,13 @@ log_end(S, [], [], Sync) -> log_end(S, Pids, Bins, Sync) -> case do_log(get(log), rflat(Bins)) of N when is_integer(N) -> - replies(Pids, ok), + ok = replies(Pids, ok), S1 = (state_ok(S))#state{cnt = S#state.cnt+N}, log_end_sync(S1, Sync); {error, {error, {full, _Name}}, N} when Pids =:= [] -> log_end_sync(state_ok(S#state{cnt = S#state.cnt + N}), Sync); {error, Error, N} -> - replies(Pids, Error), + ok = replies(Pids, Error), state_err(S#state{cnt = S#state.cnt + N}, Error) end. @@ -1091,7 +1091,7 @@ log_end_sync(S, []) -> S; log_end_sync(S, Sync) -> Res = do_sync(get(log)), - replies(Sync, Res), + ok = replies(Sync, Res), state_err(S, Res). %% Inlined. @@ -1183,7 +1183,7 @@ do_exit(S, From, Message0, Reason) -> _ -> Message0 end, _ = disk_log_server:close(self()), - replies(From, Message), + ok = replies(From, Message), ?PROFILE(ep:done()), exit(Reason). @@ -1881,7 +1881,8 @@ replies(Pids, Reply) -> send_reply(Pids, M). send_reply(Pid, M) when is_pid(Pid) -> - Pid ! M; + Pid ! M, + ok; send_reply([Pid | Pids], M) -> Pid ! M, send_reply(Pids, M); @@ -2022,7 +2023,7 @@ notify_owners(Note) -> cache_error(S, Pids) -> Error = S#state.cache_error, - replies(Pids, Error), + ok = replies(Pids, Error), state_err(S#state{cache_error = ok}, Error). state_ok(S) -> diff --git a/lib/kernel/src/disk_log_1.erl b/lib/kernel/src/disk_log_1.erl index 9d431bdd30..59f5cad001 100644 --- a/lib/kernel/src/disk_log_1.erl +++ b/lib/kernel/src/disk_log_1.erl @@ -295,12 +295,18 @@ read_chunk_ro(FdC, FileName, Pos, MaxBytes) -> pread(FdC, FileName, Pos + ?HEADSZ, MaxBytes). %% -> ok | throw(Error) -close(#cache{fd = Fd, c = []}, _FileName, read_only) -> - file:close(Fd); +close(#cache{fd = Fd, c = []}, FileName, read_only) -> + case file:close(Fd) of + ok -> ok; + Error -> file_error(FileName, Error) + end; close(#cache{fd = Fd, c = C}, FileName, read_write) -> {Reply, _NewFdC} = write_cache(Fd, FileName, C), mark(Fd, FileName, ?CLOSED), - file:close(Fd), + case file:close(Fd) of + ok -> ok; + Error -> file_error(FileName, Error) + end, if Reply =:= ok -> ok; true -> throw(Reply) end. %% Open an internal file. Head is ignored if Mode is read_only. @@ -320,7 +326,10 @@ int_open(FName, Repair, read_write, Head) -> {ok, FileHead} -> case is_head(FileHead) of yes -> - file:close(Fd), + case file:close(Fd) of + ok -> ok; + Error2 -> file_error(FName, Error2) + end, case open_update(FName) of {ok, Fd2} -> mark(Fd2, FName, ?OPENED), @@ -333,14 +342,14 @@ int_open(FName, Repair, read_write, Head) -> yes_not_closed when Repair -> repair(Fd, FName); yes_not_closed when not Repair -> - file:close(Fd), + _ = file:close(Fd), throw({error, {need_repair, FName}}); no -> - file:close(Fd), + _ = file:close(Fd), throw({error, {not_a_log_file, FName}}) end; eof -> - file:close(Fd), + _= file:close(Fd), throw({error, {not_a_log_file, FName}}); Error -> file_error_close(Fd, FName, Error) @@ -363,11 +372,11 @@ int_open(FName, _Repair, read_only, _Head) -> FdC = #cache{fd = Fd}, {ok, {existed, FdC, {0, 0}, P}}; no -> - file:close(Fd), + _= file:close(Fd), throw({error, {not_a_log_file, FName}}) end; eof -> - file:close(Fd), + _ = file:close(Fd), throw({error, {not_a_log_file, FName}}); Error -> file_error_close(Fd, FName, Error) @@ -398,7 +407,7 @@ int_log_head(Fd, Head) -> none -> {#cache{fd = Fd}, 0, 0}; Error -> - file:close(Fd), + _= file:close(Fd), throw(Error) end. @@ -450,13 +459,13 @@ ext_log_head(Fd, Head) -> none -> {#cache{fd = Fd}, {0, 0}}; Error -> - file:close(Fd), + _= file:close(Fd), throw(Error) end. %% -> _Any | throw() mark(Fd, FileName, What) -> - position_close2(Fd, FileName, 4), + {ok, _} = position_close2(Fd, FileName, 4), fwrite_close2(Fd, FileName, What). %% -> {ok, Bin} | Error @@ -560,7 +569,7 @@ scan_f2(B, FSz, Ack, No, Bad, Size, Tail) -> end. done_scan(In, Out, OutName, FName, RecoveredTerms, BadChars) -> - file:close(In), + _ = file:close(In), case catch fclose(Out, OutName) of ok -> case file:rename(OutName, FName) of @@ -574,21 +583,21 @@ done_scan(In, Out, OutName, FName, RecoveredTerms, BadChars) -> file_error(FName, Error) end; Error -> - file:delete(OutName), + _ = file:delete(OutName), file_error(FName, Error) end; Error -> - file:delete(OutName), + _ = file:delete(OutName), throw(Error) end. -spec repair_err(file:io_device(), #cache{}, file:filename(), file:filename(), {'error', file:posix()}) -> no_return(). repair_err(In, Out, OutName, ErrFileName, Error) -> - file:close(In), + _= file:close(In), catch fclose(Out, OutName), %% OutName is often the culprit, try to remove it anyway... - file:delete(OutName), + _ = file:delete(OutName), file_error(ErrFileName, Error). %% Used by wrap_log_reader. @@ -764,10 +773,10 @@ mf_int_chunk(Handle, {FileNo, Pos}, Bin, N) -> {ok, {_Alloc, FdC, _HeadSize, _FileSize}} -> case chunk(FdC, FName, Pos, Bin, N) of {NewFdC, eof} -> - file:close(NewFdC#cache.fd), + _ = file:close(NewFdC#cache.fd), mf_int_chunk(Handle, {NFileNo, 0}, [], N); {NewFdC, Other} -> - file:close(NewFdC#cache.fd), + _ = file:close(NewFdC#cache.fd), {Handle, conv(Other, FileNo)} end end. @@ -792,10 +801,10 @@ mf_int_chunk_read_only(Handle, {FileNo, Pos}, Bin, N) -> {ok, {_Alloc, FdC, _HeadSize, _FileSize}} -> case do_chunk_read_only(FdC, FName, Pos, Bin, N) of {NewFdC, eof} -> - file:close(NewFdC#cache.fd), + _ = file:close(NewFdC#cache.fd), mf_int_chunk_read_only(Handle, {NFileNo,0}, [], N); {NewFdC, Other} -> - file:close(NewFdC#cache.fd), + _ = file:close(NewFdC#cache.fd), {Handle, conv(Other, FileNo)} end end. @@ -1017,7 +1026,7 @@ ext_file_open(FName, NewFile, OldFile, OldCnt, Head, Repair, Mode) -> read_index_file(truncate, FName, MaxF) -> remove_files(FName, 2, MaxF), - file:delete(?index_file_name(FName)), + _ = file:delete(?index_file_name(FName)), {1, 0, 0, 0}; read_index_file(_, FName, _MaxF) -> read_index_file(FName). @@ -1043,7 +1052,7 @@ read_index_file(FName) -> _ErrorOrEof -> {1, 0, 0, 0} end, - file:close(Fd), + _ = file:close(Fd), R; _Error -> {1, 0, 0, 0} @@ -1096,7 +1105,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) -> %% Very old format, convert to the latest format! case file:read_file(FileName) of {ok, <<_CurF, Tail/binary>>} -> - position_close2(Fd, FileName, bof), + {ok, _} = position_close2(Fd, FileName, bof), Bin = <<0, 0:32, ?VERSION, NewFile:32>>, NewTail = to_8_bytes(Tail, [], FileName, Fd), fwrite_close2(Fd, FileName, [Bin | NewTail]), @@ -1115,7 +1124,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) -> R = file:pread(Fd, NewPos, SzSz), OldPos = Offset + (OldFile - 1)*SzSz, pwrite_close2(Fd, FileName, OldPos, OldCntBin), - file:close(Fd), + _ = file:close(Fd), case R of {ok, <<Lost:SzSz/unit:8>>} -> Lost; {ok, _} -> @@ -1125,7 +1134,7 @@ write_index_file(read_write, FName, NewFile, OldFile, OldCnt) -> end; true -> pwrite_close2(Fd, FileName, NewPos, OldCntBin), - file:close(Fd), + _ = file:close(Fd), 0 end; E -> @@ -1137,7 +1146,7 @@ to_8_bytes(<<N:32,T/binary>>, NT, FileName, Fd) -> to_8_bytes(B, NT, _FileName, _Fd) when byte_size(B) =:= 0 -> NT; to_8_bytes(_B, _NT, FileName, Fd) -> - file:close(Fd), + _ = file:close(Fd), throw({error, {invalid_index_file, FileName}}). %% -> ok | throw(FileError) @@ -1147,7 +1156,7 @@ index_file_trunc(FName, N) -> {ok, Fd} -> case file:read(Fd, 6) of eof -> - file:close(Fd), + _ = file:close(Fd), ok; {ok, <<0, 0:32, Version>>} when Version =:= ?VERSION -> truncate_index_file(Fd, FileName, 10, 8, N); @@ -1166,10 +1175,10 @@ truncate_index_file(Fd, FileName, Offset, N, SzSz) -> Pos = Offset + N*SzSz, case Pos > file_size(FileName) of true -> - file:close(Fd); + ok = file:close(Fd); false -> truncate_at_close2(Fd, FileName, {bof, Pos}), - file:close(Fd) + ok = file:close(Fd) end, ok. @@ -1412,7 +1421,8 @@ fwrite(#cache{c = []} = FdC, _FN, B, Size) -> ok; _ -> put(write_cache_timer_is_running, true), - erlang:send_after(?TIMEOUT, self(), {self(), write_cache}) + erlang:send_after(?TIMEOUT, self(), {self(), write_cache}), + ok end, {ok, FdC#cache{sz = Size, c = B}}; fwrite(#cache{sz = Sz, c = C} = FdC, _FN, B, Size) when Sz < ?MAX -> @@ -1511,7 +1521,7 @@ position_close2(Fd, FileName, Pos) -> end. truncate_at_close2(Fd, FileName, Pos) -> - position_close2(Fd, FileName, Pos), + {ok, _} = position_close2(Fd, FileName, Pos), case file:truncate(Fd) of ok -> ok; Error -> file_error_close(Fd, FileName, Error) @@ -1519,7 +1529,7 @@ truncate_at_close2(Fd, FileName, Pos) -> fclose(#cache{fd = Fd, c = C}, FileName) -> %% The cache is empty if the file was opened in read_only mode. - write_cache_close(Fd, FileName, C), + _ = write_cache_close(Fd, FileName, C), file:close(Fd). %% -> {Reply, #cache{}}; Reply = ok | Error @@ -1549,5 +1559,5 @@ file_error(FileName, {error, Error}) -> -spec file_error_close(file:fd(), file:filename(), {'error', file:posix()}) -> no_return(). file_error_close(Fd, FileName, {error, Error}) -> - file:close(Fd), + _ = file:close(Fd), throw({error, {file_error, FileName, Error}}). diff --git a/lib/kernel/src/disk_log_server.erl b/lib/kernel/src/disk_log_server.erl index 8894ed87e8..45334912eb 100644 --- a/lib/kernel/src/disk_log_server.erl +++ b/lib/kernel/src/disk_log_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. 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 @@ -83,8 +83,8 @@ accessible_logs() -> init([]) -> process_flag(trap_exit, true), - ets:new(?DISK_LOG_NAME_TABLE, [named_table, set]), - ets:new(?DISK_LOG_PID_TABLE, [named_table, set]), + _ = ets:new(?DISK_LOG_NAME_TABLE, [named_table, set]), + _= ets:new(?DISK_LOG_PID_TABLE, [named_table, set]), {ok, #state{}}. handle_call({open, W, A}, From, State) -> @@ -159,15 +159,25 @@ ensure_started() -> undefined -> LogSup = {disk_log_sup, {disk_log_sup, start_link, []}, permanent, 1000, supervisor, [disk_log_sup]}, - supervisor:start_child(kernel_safe_sup, LogSup), + {ok, _} = ensure_child_started(kernel_safe_sup, LogSup), LogServer = {disk_log_server, {disk_log_server, start_link, []}, permanent, 2000, worker, [disk_log_server]}, - supervisor:start_child(kernel_safe_sup, LogServer), + {ok, _} = ensure_child_started(kernel_safe_sup, LogServer), ok; _ -> ok end. +ensure_child_started(Sup,Child) -> + case supervisor:start_child(Sup, Child) of + {ok,Pid} -> + {ok,Pid}; + {error,{already_started,Pid}} -> + {ok,Pid}; + Error -> + Error + end. + open([{Req, From} | L], State) -> State2 = case do_open(Req, From, State) of {pending, State1} -> @@ -189,7 +199,7 @@ do_open({open, W, #arg{name = Name}=A}=Req, From, State) -> false when W =:= local -> case A#arg.distributed of {true, Nodes} -> - Fun = fun() -> open_distr_rpc(Nodes, A, From) end, + Fun = open_distr_rpc_fun(Nodes, A, From), _Pid = spawn(Fun), %% No pending reply is expected, but don't reply yet. {pending, State}; @@ -215,11 +225,15 @@ do_open({open, W, #arg{name = Name}=A}=Req, From, State) -> end end. +-spec open_distr_rpc_fun([node()], _, _) -> % XXX: underspecified + fun(() -> no_return()). + +open_distr_rpc_fun(Nodes, A, From) -> + fun() -> open_distr_rpc(Nodes, A, From) end. + %% Spawning a process is a means to avoid deadlock when %% disk_log_servers mutually open disk_logs. --spec open_distr_rpc([node()], _, _) -> no_return(). % XXX: underspecified - open_distr_rpc(Nodes, A, From) -> {AllReplies, BadNodes} = rpc:multicall(Nodes, ?MODULE, dist_open, [A]), {Ok, Bad} = cr(AllReplies, [], []), diff --git a/lib/kernel/src/dist_ac.erl b/lib/kernel/src/dist_ac.erl index 5c62aa31e9..a4d4ae386c 100644 --- a/lib/kernel/src/dist_ac.erl +++ b/lib/kernel/src/dist_ac.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% Copyright Ericsson AB 1997-2013. 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 @@ -283,7 +283,7 @@ handle_cast(init_sync, _S) -> KernelConfig ! dist_ac_took_control, %% we're really just interested in nodedowns. - net_kernel:monitor_nodes(true), + ok = net_kernel:monitor_nodes(true), {Known, NAppls, RStarted} = sync_dacs(Appls), @@ -321,7 +321,7 @@ handle_call({takeover_application, AppName, RestartType}, From, S) -> case keysearch(AppName, #appl.name, Appls) of {value, Appl} when element(1, Appl#appl.id) =:= distributed -> {distributed, Node} = Appl#appl.id, - ac_takeover(req, AppName, Node, RestartType), + _ = ac_takeover(req, AppName, Node, RestartType), NAppl = Appl#appl{id = takeover}, NAppls = keyreplace(AppName, #appl.name, Appls, NAppl), TR = S#state.t_reqs, @@ -341,10 +341,10 @@ handle_call({permit_application, AppName, Bool, LockId, StartInfo}, From, S) -> %% here, but we have to be backwards-compatible. case application_controller:get_loaded(AppName) of {true, _} when not Bool -> - ac_stop_it(AppName), + _ = ac_stop_it(AppName), {reply, ok, S}; {true, _} when Bool -> - ac_start_it(req, AppName), + _ = ac_start_it(req, AppName), {reply, ok, S}; false -> {reply, {error, {not_loaded, AppName}}, S} @@ -533,7 +533,7 @@ handle_info({dist_ac_app_started, Node, Name, Res}, S) -> %% Another node started appl. Update appl list. {distributed, Node} end, - ac_started(req, Name, Node), + _ = ac_started(req, Name, Node), NAppl = Appl#appl{id = NId}, NAppls = keyreplace(Name, #appl.name, Appls, NAppl), TmpWeights = keydelete_all(Name, 1, S#state.tmp_weights), @@ -622,7 +622,7 @@ handle_info({nodedown, Node}, S) -> true -> {true, Appl#appl{id = {failover, Node}}}; false -> - ac_not_running(Appl#appl.name), + _ = ac_not_running(Appl#appl.name), {true, Appl#appl{id = undefined}} end; (_) -> @@ -656,7 +656,8 @@ handle_info({dist_ac_app_loaded, Node, Name, HisNodes, Permission, HeKnowsMe}, %% he's a new node connecting to us. Msg = {dist_ac_app_loaded, node(), Name, Nodes, dist_is_runnable(Appls, Name), true}, - {?DIST_AC, Node} ! Msg; + {?DIST_AC, Node} ! Msg, + ok; true -> ok end, @@ -811,29 +812,29 @@ start_appl(AppName, S, Type) -> start_distributed(Appl, Name, Nodes, PermittedNodes, S, Type) -> case find_start_node(Nodes, PermittedNodes, Name, S) of {ok, Node} when Node =:= node() -> - case Appl#appl.id of - {failover, FoNode} when Type =:= req -> - ac_failover(Name, FoNode, undefined); - {distributed, Node2} when Type =:= req -> - ac_takeover(req, Name, Node2, undefined); - _ when Type =:= reply -> - case lists:keysearch(Name, 2, S#state.remote_started) of - {value, {Node3, _}} -> - ac_takeover(reply, Name, Node3, undefined); - _ -> - ac_start_it(Type, Name) - end; - _ -> - ac_start_it(Type, Name) - end, + _ = case Appl#appl.id of + {failover, FoNode} when Type =:= req -> + ac_failover(Name, FoNode, undefined); + {distributed, Node2} when Type =:= req -> + ac_takeover(req, Name, Node2, undefined); + _ when Type =:= reply -> + case lists:keysearch(Name, 2, S#state.remote_started) of + {value, {Node3, _}} -> + ac_takeover(reply, Name, Node3, undefined); + _ -> + ac_start_it(Type, Name) + end; + _ -> + ac_start_it(Type, Name) + end, {run_waiting, true}; {already_started, Node} -> - ac_started(Type, Name, Node), + _ = ac_started(Type, Name, Node), {{distributed, Node}, false}; {ok, Node} -> case keysearch(Name, #appl.name, S#state.appls) of {value, #appl{id = {distributed, Node}}} -> - ac_started(Type, Name, Node), + _ = ac_started(Type, Name, Node), {{distributed, Node}, false}; _ -> wait_dist_start(Node, Appl, Name, Nodes, @@ -842,7 +843,7 @@ start_distributed(Appl, Name, Nodes, PermittedNodes, S, Type) -> not_started -> wait_dist_start2(Appl, Name, Nodes, PermittedNodes, S, Type); no_permission -> - ac_not_started(Type, Name), + _ = ac_not_started(Type, Name), {undefined, false} end. @@ -850,11 +851,11 @@ wait_dist_start(Node, Appl, Name, Nodes, PermittedNodes, S, Type) -> monitor_node(Node, true), receive {dist_ac_app_started, Node, Name, ok} -> - ac_started(Type, Name, Node), + _ = ac_started(Type, Name, Node), monitor_node(Node, false), {{distributed, Node}, false}; {dist_ac_app_started, Node, Name, {error, R}} -> - ac_error(Type, Name, {Node, R}), + _ = ac_error(Type, Name, {Node, R}), monitor_node(Node, false), {Appl#appl.id, false}; {dist_ac_weight, Name, _Weigth, Node} -> @@ -883,10 +884,10 @@ wait_dist_start(Node, Appl, Name, Nodes, PermittedNodes, S, Type) -> wait_dist_start2(Appl, Name, Nodes, PermittedNodes, S, Type) -> receive {dist_ac_app_started, Node, Name, ok} -> - ac_started(Type, Name, Node), + _ = ac_started(Type, Name, Node), {{distributed, Node}, false}; {dist_ac_app_started, Node, Name, {error, R}} -> - ac_error(Type, Name, {Node, R}), + _ = ac_error(Type, Name, {Node, R}), {Appl#appl.id, false}; {nodedown, Node} -> %% A node went down, try to start the app again - there may not @@ -974,7 +975,7 @@ permit(false, {value, _}, AppName, From, S, _LockId) -> case dist_get_runnable_nodes(S#state.appls, AppName) of [] -> %% There is no runnable node; stop application - ac_stop_it(AppName), + _ = ac_stop_it(AppName), SReqs = [{AppName, From} | S#state.s_reqs], {noreply, S#state{s_reqs = SReqs}}; Nodes -> @@ -1155,7 +1156,8 @@ send_nodes(Nodes, Msg) -> end, FlatNodes). send_after(Time, Msg) when is_integer(Time), Time >= 0 -> - spawn_link(?MODULE, send_timeout, [self(), Time, Msg]); + _Pid = spawn_link(?MODULE, send_timeout, [self(), Time, Msg]), + ok; send_after(_,_) -> % infinity ok. @@ -1305,7 +1307,7 @@ check_waiting([{From, AppName, false, Nodes} | Reqs], S, Node, Appls, Res, SReqs) -> case lists:delete(Node, Nodes) of [] -> - ac_stop_it(AppName), + _ = ac_stop_it(AppName), NSReqs = [{AppName, From} | SReqs], check_waiting(Reqs, Node, S, Appls, Res, NSReqs); NNodes -> diff --git a/lib/kernel/src/dist_util.erl b/lib/kernel/src/dist_util.erl index fc50ec6717..b127fe2e33 100644 --- a/lib/kernel/src/dist_util.erl +++ b/lib/kernel/src/dist_util.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2013. All Rights Reserved. +%% Copyright Ericsson AB 1999-2014. 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 @@ -116,7 +116,8 @@ make_this_flags(RequestType, OtherNode) -> ?DFLAG_UNICODE_IO bor ?DFLAG_DIST_HDR_ATOM_CACHE bor ?DFLAG_SMALL_ATOM_TAGS bor - ?DFLAG_UTF8_ATOMS). + ?DFLAG_UTF8_ATOMS bor + ?DFLAG_MAP_TAG). handshake_other_started(#hs_data{request_type=ReqType}=HSData0) -> {PreOtherFlags,Node,Version} = recv_name(HSData0), diff --git a/lib/kernel/src/erl_boot_server.erl b/lib/kernel/src/erl_boot_server.erl index 0d68d3e198..9a49655a9f 100644 --- a/lib/kernel/src/erl_boot_server.erl +++ b/lib/kernel/src/erl_boot_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. 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 @@ -191,7 +191,7 @@ init(Slaves) -> {ok, UPort} = inet:port(U), Ref = make_ref(), Pid = proc_lib:spawn_link(?MODULE, boot_init, [Ref]), - gen_tcp:controlling_process(L, Pid), + ok = gen_tcp:controlling_process(L, Pid), Pid ! {Ref, L}, %% We trap exit inorder to restart boot_init and udp_port process_flag(trap_exit, true), @@ -233,9 +233,19 @@ handle_info({udp, U, IP, Port, Data}, S0) -> %% erlang version as the boot server node case {Valid,Data,Token} of {true,Token,Token} -> - gen_udp:send(U,IP,Port,[?EBOOT_REPLY,S0#state.priority, - int16(S0#state.listen_port), - S0#state.version]), + case gen_udp:send(U,IP,Port,[?EBOOT_REPLY,S0#state.priority, + int16(S0#state.listen_port), + S0#state.version]) + of + ok -> ok; + {error, not_owner} -> + error_logger:error_msg("** Illegal boot server connection attempt: " + "not owner of ~w ** ~n", [U]); + {error, Reason} -> + Err = file:format_error(Reason), + error_logger:error_msg("** Illegal boot server connection attempt: " + "~w POSIX error ** ~n", [U, Err]) + end, {noreply,S0}; {false,_,_} -> error_logger:error_msg("** Illegal boot server connection attempt: " @@ -351,7 +361,14 @@ handle_command(S, PS, Msg) -> end. send_file_result(S, Cmd, Result) -> - gen_tcp:send(S, term_to_binary({Cmd,Result})). - -send_result(S, Result) -> - gen_tcp:send(S, term_to_binary(Result)). + send_result(S, {Cmd,Result}). + +send_result(S, Term) -> + case gen_tcp:send(S, term_to_binary(Term)) of + ok -> + ok; + Error -> + error_logger:error_msg("** Boot server could not send result " + "to socket: ~w** ~n", [Error]), + ok + end. diff --git a/lib/kernel/src/erl_epmd.erl b/lib/kernel/src/erl_epmd.erl index 91af49f303..b4fae24ef3 100644 --- a/lib/kernel/src/erl_epmd.erl +++ b/lib/kernel/src/erl_epmd.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2010. All Rights Reserved. +%% Copyright Ericsson AB 1998-2013. 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 @@ -217,17 +217,23 @@ do_register_node(NodeName, TcpPort) -> Extra = "", Elen = length(Extra), Len = 1+2+1+1+2+2+2+length(Name)+2+Elen, - gen_tcp:send(Socket, [?int16(Len), ?EPMD_ALIVE2_REQ, - ?int16(TcpPort), - $M, - 0, - ?int16(epmd_dist_high()), - ?int16(epmd_dist_low()), - ?int16(length(Name)), - Name, - ?int16(Elen), - Extra]), - wait_for_reg_reply(Socket, []); + Packet = [?int16(Len), ?EPMD_ALIVE2_REQ, + ?int16(TcpPort), + $M, + 0, + ?int16(epmd_dist_high()), + ?int16(epmd_dist_low()), + ?int16(length(Name)), + Name, + ?int16(Elen), + Extra], + case gen_tcp:send(Socket, Packet) of + ok -> + wait_for_reg_reply(Socket, []); + Error -> + close(Socket), + Error + end; Error -> Error end. @@ -294,8 +300,14 @@ get_port(Node, EpmdAddress, Timeout) -> {ok, Socket} -> Name = to_string(Node), Len = 1+length(Name), - gen_tcp:send(Socket, [?int16(Len),?EPMD_PORT_PLEASE2_REQ, Name]), - wait_for_port_reply(Socket, []); + Msg = [?int16(Len),?EPMD_PORT_PLEASE2_REQ,Name], + case gen_tcp:send(Socket, Msg) of + ok -> + wait_for_port_reply(Socket, []); + _Error -> + ?port_please_failure2(_Error), + noport + end; _Error -> ?port_please_failure2(_Error), noport @@ -374,7 +386,7 @@ wait_for_port_reply_name(Socket, Len, Sofar) -> % io:format("data = ~p~n", _Data), wait_for_port_reply_name(Socket, Len, Sofar); {tcp_closed, Socket} -> - "foobar" + ok end. @@ -424,19 +436,24 @@ get_names(EpmdAddress) -> end. do_get_names(Socket) -> - gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]), - receive - {tcp, Socket, [P0,P1,P2,P3|T]} -> - EpmdPort = ?u32(P0,P1,P2,P3), - case get_epmd_port() of - EpmdPort -> - names_loop(Socket, T, []); - _ -> - close(Socket), - {error, address} + case gen_tcp:send(Socket, [?int16(1),?EPMD_NAMES]) of + ok -> + receive + {tcp, Socket, [P0,P1,P2,P3|T]} -> + EpmdPort = ?u32(P0,P1,P2,P3), + case get_epmd_port() of + EpmdPort -> + names_loop(Socket, T, []); + _ -> + close(Socket), + {error, address} + end; + {tcp_closed, Socket} -> + {ok, []} end; - {tcp_closed, Socket} -> - {ok, []} + _ -> + close(Socket), + {error, address} end. names_loop(Socket, Acc, Ps) -> diff --git a/lib/kernel/src/erl_reply.erl b/lib/kernel/src/erl_reply.erl index 1a61e630bc..f0be3ee654 100644 --- a/lib/kernel/src/erl_reply.erl +++ b/lib/kernel/src/erl_reply.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2009. All Rights Reserved. +%% Copyright Ericsson AB 1997-2013. 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 @@ -32,7 +32,7 @@ reply([Addr,Port,Msg]) -> P = list_to_integer(atom_to_list(Port)), M = atom_to_list(Msg), {ok, S} = gen_tcp:connect(Ip,P,[]), - gen_tcp:send(S,M), + ok = gen_tcp:send(S,M), gen_tcp:close(S), reply_done; reply(_) -> diff --git a/lib/kernel/src/error_logger.erl b/lib/kernel/src/error_logger.erl index 92c1eb80dc..b8fbf02feb 100644 --- a/lib/kernel/src/error_logger.erl +++ b/lib/kernel/src/error_logger.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2012. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. 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 @@ -245,16 +245,18 @@ notify(Msg) -> -spec swap_handler(Type :: swap_handler_type()) -> any(). swap_handler(tty) -> - gen_event:swap_handler(error_logger, {error_logger, swap}, - {error_logger_tty_h, []}), - simple_logger(); + R = gen_event:swap_handler(error_logger, {error_logger, swap}, + {error_logger_tty_h, []}), + ok = simple_logger(), + R; swap_handler({logfile, File}) -> - gen_event:swap_handler(error_logger, {error_logger, swap}, - {error_logger_file_h, File}), - simple_logger(); + R = gen_event:swap_handler(error_logger, {error_logger, swap}, + {error_logger_file_h, File}), + ok = simple_logger(), + R; swap_handler(silent) -> - gen_event:delete_handler(error_logger, error_logger, delete), - simple_logger(); + _ = gen_event:delete_handler(error_logger, error_logger, delete), + ok = simple_logger(); swap_handler(false) -> ok. % keep primitive event handler as-is diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl index 6654cd9ee7..ef605d0bfe 100644 --- a/lib/kernel/src/erts_debug.erl +++ b/lib/kernel/src/erts_debug.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2012. All Rights Reserved. +%% Copyright Ericsson AB 1999-2013. 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 @@ -182,6 +182,11 @@ size(Tuple, Seen0, Sum0) when is_tuple(Tuple) -> Sum = Sum0 + 1 + tuple_size(Tuple), tuple_size(1, tuple_size(Tuple), Tuple, Seen, Sum) end; +size(Map, Seen0, Sum) when is_map(Map) -> + case remember_term(Map, Seen0) of + seen -> {Sum,Seen0}; + Seen -> map_size(Map, Seen, Sum) + end; size(Fun, Seen0, Sum) when is_function(Fun) -> case remember_term(Fun, Seen0) of seen -> {Sum,Seen0}; @@ -203,6 +208,12 @@ tuple_size(I, Sz, Tuple, Seen0, Sum0) -> {Sum,Seen} = size(element(I, Tuple), Seen0, Sum0), tuple_size(I+1, Sz, Tuple, Seen, Sum). +map_size(Map,Seen0,Sum0) -> + Kt = erts_internal:map_to_tuple_keys(Map), + Vs = maps:values(Map), + {Sum1,Seen1} = size(Kt,Seen0,Sum0), + fold_size(Vs,Seen1,Sum1+length(Vs)+3). + fun_size(Fun, Seen, Sum) -> case erlang:fun_info(Fun, type) of {type,external} -> @@ -210,14 +221,14 @@ fun_size(Fun, Seen, Sum) -> {type,local} -> Sz = erts_debug:flat_size(fun() -> ok end), {env,Env} = erlang:fun_info(Fun, env), - fun_size_1(Env, Seen, Sum+Sz+length(Env)) + fold_size(Env, Seen, Sum+Sz+length(Env)) end. -fun_size_1([H|T], Seen0, Sum0) -> +fold_size([H|T], Seen0, Sum0) -> {Sum,Seen} = size(H, Seen0, Sum0), - fun_size_1(T, Seen, Sum); -fun_size_1([], Seen, Sum) -> {Sum,Seen}. - + fold_size(T, Seen, Sum); +fold_size([], Seen, Sum) -> {Sum,Seen}. + remember_term(Term, Seen) -> case gb_trees:lookup(Term, Seen) of none -> gb_trees:insert(Term, [Term], Seen); @@ -288,7 +299,7 @@ dff(Name, Fs) when is_list(Name) -> try dff(F, Fs) after - file:close(F) + _ = file:close(F) end; {error,Reason} -> {error,{badopen,Reason}} diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index 36289053eb..20b703e084 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -95,7 +95,8 @@ Delay :: non_neg_integer()} | 'delayed_write' | {'read_ahead', Size :: pos_integer()} | 'read_ahead' | 'compressed' - | {'encoding', unicode:encoding()}. + | {'encoding', unicode:encoding()} + | sync. -type deep_list() :: [char() | atom() | deep_list()]. -type name() :: string() | atom() | deep_list(). -type name_all() :: string() | atom() | deep_list() | (RawFilename :: binary()). @@ -110,7 +111,8 @@ -type date_time() :: calendar:datetime(). -type posix_file_advise() :: 'normal' | 'sequential' | 'random' | 'no_reuse' | 'will_need' | 'dont_need'. --type sendfile_option() :: {chunk_size, non_neg_integer()}. +-type sendfile_option() :: {chunk_size, non_neg_integer()} + | {use_threads, boolean()}. -type file_info_option() :: {'time', 'local'} | {'time', 'universal'} | {'time', 'posix'}. %%% BIFs @@ -197,7 +199,8 @@ get_cwd(Drive) -> check_and_call(get_cwd, [file_name(Drive)]). -spec set_cwd(Dir) -> ok | {error, Reason} when - Dir :: name(), + Dir :: name() | EncodedBinary, + EncodedBinary :: binary(), Reason :: posix() | badarg | no_translation. set_cwd(Dirname) -> @@ -376,7 +379,7 @@ write_file(Name, Bin, ModeList) when is_list(ModeList) -> ok -> close(Handle); E1 -> - close(Handle), + _ = close(Handle), E1 end; E2 -> @@ -770,7 +773,7 @@ copy_int({SourceName, SourceOpts}, Dest, Length) case open(Source, [read | SourceOpts]) of {ok, Handle} -> Result = copy_opened_int(Handle, Dest, Length, 0), - close(Handle), + _ = close(Handle), Result; {error, _} = Error -> Error @@ -786,9 +789,16 @@ copy_int(Source, {DestName, DestOpts}, Length) Dest -> case open(Dest, [write | DestOpts]) of {ok, Handle} -> - Result = copy_opened_int(Source, Handle, Length, 0), - close(Handle), - Result; + case copy_opened_int(Source, Handle, Length, 0) of + {ok, _} = OK -> + case close(Handle) of + ok -> OK; + Error -> Error + end; + Error -> + _ = close(Handle), + Error + end; {error, _} = Error -> Error end @@ -957,7 +967,7 @@ consult(File) -> case open(File, [read]) of {ok, Fd} -> R = consult_stream(Fd), - close(Fd), + _ = close(Fd), R; Error -> Error @@ -977,10 +987,10 @@ path_consult(Path, File) -> {ok, Fd, Full} -> case consult_stream(Fd) of {ok, List} -> - close(Fd), + _ = close(Fd), {ok, List, Full}; E1 -> - close(Fd), + _ = close(Fd), E1 end; E2 -> @@ -1005,7 +1015,7 @@ eval(File, Bs) -> case open(File, [read]) of {ok, Fd} -> R = eval_stream(Fd, ignore, Bs), - close(Fd), + _ = close(Fd), R; Error -> Error @@ -1035,10 +1045,10 @@ path_eval(Path, File, Bs) -> {ok, Fd, Full} -> case eval_stream(Fd, ignore, Bs) of ok -> - close(Fd), + _ = close(Fd), {ok, Full}; E1 -> - close(Fd), + _ = close(Fd), E1 end; E2 -> @@ -1065,7 +1075,7 @@ script(File, Bs) -> case open(File, [read]) of {ok, Fd} -> R = eval_stream(Fd, return, Bs), - close(Fd), + _ = close(Fd), R; Error -> Error @@ -1098,10 +1108,10 @@ path_script(Path, File, Bs) -> {ok,Fd,Full} -> case eval_stream(Fd, return, Bs) of {ok,R} -> - close(Fd), + _ = close(Fd), {ok, R, Full}; E1 -> - close(Fd), + _ = close(Fd), E1 end; E2 -> @@ -1221,8 +1231,7 @@ change_time(Name, {{AY, AM, AD}, {AH, AMin, ASec}}=Atime, sendfile(File, _Sock, _Offet, _Bytes, _Opts) when is_pid(File) -> {error, badarg}; sendfile(File, Sock, Offset, Bytes, []) -> - sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [], - false, false, false); + sendfile(File, Sock, Offset, Bytes, ?MAX_CHUNK_SIZE, [], [], []); sendfile(File, Sock, Offset, Bytes, Opts) -> ChunkSize0 = proplists:get_value(chunk_size, Opts, ?MAX_CHUNK_SIZE), ChunkSize = if ChunkSize0 > ?MAX_CHUNK_SIZE -> @@ -1232,8 +1241,7 @@ sendfile(File, Sock, Offset, Bytes, Opts) -> %% Support for headers, trailers and options has been removed because the %% Darwin and BSD API for using it does not play nice with %% non-blocking sockets. See unix_efile.c for more info. - sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [], - false,false,false). + sendfile(File, Sock, Offset, Bytes, ChunkSize, [], [], Opts). %% sendfile/2 -spec sendfile(Filename, Socket) -> @@ -1247,23 +1255,23 @@ sendfile(Filename, Sock) -> {error, Reason}; {ok, Fd} -> Res = sendfile(Fd, Sock, 0, 0, []), - file:close(Fd), + _ = file:close(Fd), Res end. %% Internal sendfile functions sendfile(#file_descriptor{ module = Mod } = Fd, Sock, Offset, Bytes, - ChunkSize, Headers, Trailers, Nodiskio, MNowait, Sync) + ChunkSize, Headers, Trailers, Opts) when is_port(Sock) -> case Mod:sendfile(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers, - Nodiskio, MNowait, Sync) of + Opts) of {error, enotsup} -> sendfile_fallback(Fd, Sock, Offset, Bytes, ChunkSize, Headers, Trailers); Else -> Else end; -sendfile(_,_,_,_,_,_,_,_,_,_) -> +sendfile(_,_,_,_,_,_,_,_) -> {error, badarg}. %%% @@ -1298,7 +1306,7 @@ sendfile_fallback(File, Sock, Offset, Bytes, ChunkSize) -> {ok, CurrPos} = file:position(File, {cur, 0}), {ok, _NewPos} = file:position(File, {bof, Offset}), Res = sendfile_fallback_int(File, Sock, Bytes, ChunkSize, 0), - file:position(File, {bof, CurrPos}), + _ = file:position(File, {bof, CurrPos}), Res. diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl index 0bcb1a658b..0e9ff5bc0f 100644 --- a/lib/kernel/src/file_io_server.erl +++ b/lib/kernel/src/file_io_server.erl @@ -162,29 +162,29 @@ server_loop(#state{mref = Mref} = State) -> {file_request, From, ReplyAs, Request} when is_pid(From) -> case file_request(Request, State) of {reply, Reply, NewState} -> - file_reply(From, ReplyAs, Reply), + _ = file_reply(From, ReplyAs, Reply), server_loop(NewState); {error, Reply, NewState} -> %% error is the same as reply, except that %% it breaks the io_request_loop further down - file_reply(From, ReplyAs, Reply), + _ = file_reply(From, ReplyAs, Reply), server_loop(NewState); {stop, Reason, Reply, _NewState} -> - file_reply(From, ReplyAs, Reply), + _ = file_reply(From, ReplyAs, Reply), exit(Reason) end; {io_request, From, ReplyAs, Request} when is_pid(From) -> case io_request(Request, State) of {reply, Reply, NewState} -> - io_reply(From, ReplyAs, Reply), + _ = io_reply(From, ReplyAs, Reply), server_loop(NewState); {error, Reply, NewState} -> %% error is the same as reply, except that %% it breaks the io_request_loop further down - io_reply(From, ReplyAs, Reply), + _ = io_reply(From, ReplyAs, Reply), server_loop(NewState); {stop, Reason, Reply, _NewState} -> - io_reply(From, ReplyAs, Reply), + _ = io_reply(From, ReplyAs, Reply), exit(Reason) end; {'DOWN', Mref, _, _, Reason} -> diff --git a/lib/kernel/src/file_server.erl b/lib/kernel/src/file_server.erl index d036dbb516..eabf0401a3 100644 --- a/lib/kernel/src/file_server.erl +++ b/lib/kernel/src/file_server.erl @@ -78,7 +78,8 @@ init([]) -> process_flag(trap_exit, true), case ?PRIM_FILE:start() of {ok, Handle} -> - ets:new(?FILE_IO_SERVER_TABLE, [named_table]), + ?FILE_IO_SERVER_TABLE = + ets:new(?FILE_IO_SERVER_TABLE, [named_table]), {ok, Handle}; {error, Reason} -> {stop, Reason} diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl index 067e07304d..adaa3159ec 100644 --- a/lib/kernel/src/gen_sctp.erl +++ b/lib/kernel/src/gen_sctp.erl @@ -36,7 +36,7 @@ -type assoc_id() :: term(). -type option() :: - {active, true | false | once} | + {active, true | false | once | -32768..32767} | {buffer, non_neg_integer()} | {dontroute, boolean()} | {high_msgq_watermark, pos_integer()} | @@ -274,7 +274,7 @@ do_connect(S, Addr, Port, Opts, Timeout, ConnWait) when is_port(S), is_list(Opts Mod:connect(S, IP, Port, Opts, ConnectTimer); Error -> Error after - inet:stop_timer(Timer) + _ = inet:stop_timer(Timer) end catch error:badarg -> diff --git a/lib/kernel/src/gen_tcp.erl b/lib/kernel/src/gen_tcp.erl index a98ed4c238..bc8ffbe5e3 100644 --- a/lib/kernel/src/gen_tcp.erl +++ b/lib/kernel/src/gen_tcp.erl @@ -30,7 +30,7 @@ -include("file.hrl"). -type option() :: - {active, true | false | once} | + {active, true | false | once | -32768..32767} | {buffer, non_neg_integer()} | {delay_send, boolean()} | {deliver, port | term} | @@ -139,7 +139,7 @@ connect(Address, Port, Opts) -> connect(Address, Port, Opts, Time) -> Timer = inet:start_timer(Time), Res = (catch connect1(Address,Port,Opts,Timer)), - inet:stop_timer(Timer), + _ = inet:stop_timer(Timer), case Res of {ok,S} -> {ok,S}; {error, einval} -> exit(badarg); diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl index e82b11d2ef..70dceb3679 100644 --- a/lib/kernel/src/gen_udp.erl +++ b/lib/kernel/src/gen_udp.erl @@ -26,7 +26,7 @@ -include("inet_int.hrl"). -type option() :: - {active, true | false | once} | + {active, true | false | once | -32768..32767} | {add_membership, {inet:ip_address(), inet:ip_address()}} | {broadcast, boolean()} | {buffer, non_neg_integer()} | diff --git a/lib/kernel/src/global.erl b/lib/kernel/src/global.erl index b24a9d5eac..0a4edea452 100644 --- a/lib/kernel/src/global.erl +++ b/lib/kernel/src/global.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2012. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. 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 @@ -1513,14 +1513,18 @@ delete_global_name(_Name, _Pid) -> -record(him, {node, locker, vsn, my_tag}). start_the_locker(DoTrace) -> - spawn_link(fun() -> init_the_locker(DoTrace) end). + spawn_link(init_the_locker_fun(DoTrace)). -init_the_locker(DoTrace) -> - process_flag(trap_exit, true), % needed? - S0 = #multi{do_trace = DoTrace}, - S1 = update_locker_known({add, get_known()}, S0), - loop_the_locker(S1), - erlang:error(locker_exited). +-spec init_the_locker_fun(boolean()) -> fun(() -> no_return()). + +init_the_locker_fun(DoTrace) -> + fun() -> + process_flag(trap_exit, true), % needed? + S0 = #multi{do_trace = DoTrace}, + S1 = update_locker_known({add, get_known()}, S0), + loop_the_locker(S1), + erlang:error(locker_exited) + end. loop_the_locker(S) -> ?trace({loop_the_locker,S}), @@ -2069,7 +2073,8 @@ random_sleep(Times) -> case get(random_seed) of undefined -> {A1, A2, A3} = now(), - random:seed(A1, A2, A3 + erlang:phash(node(), 100000)); + _ = random:seed(A1, A2, A3 + erlang:phash(node(), 100000)), + ok; _ -> ok end, %% First time 1/4 seconds, then doubling each time up to 8 seconds max. diff --git a/lib/kernel/src/global_group.erl b/lib/kernel/src/global_group.erl index 025a9b8a5b..da8b573749 100644 --- a/lib/kernel/src/global_group.erl +++ b/lib/kernel/src/global_group.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2011. All Rights Reserved. +%% Copyright Ericsson AB 1998-2013. 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 @@ -1149,9 +1149,14 @@ do_unlink(Pid, State) -> %%%==================================================================================== %%% Send a nodeup/down messages to monitoring Pids in the own global group. %%%==================================================================================== -send_monitor([P|T], M, no_conf) -> safesend_nc(P, M), send_monitor(T, M, no_conf); -send_monitor([P|T], M, SyncState) -> safesend(P, M), send_monitor(T, M, SyncState); -send_monitor([], _, _) -> ok. +send_monitor([P|T], M, no_conf) -> + _ = safesend_nc(P, M), + send_monitor(T, M, no_conf); +send_monitor([P|T], M, SyncState) -> + _ = safesend(P, M), + send_monitor(T, M, SyncState); +send_monitor([], _, _) -> + ok. safesend(Name, {Msg, Node}) when is_atom(Name) -> case lists:member(Node, get_own_nodes()) of diff --git a/lib/kernel/src/group.erl b/lib/kernel/src/group.erl index ff835e1047..b36dbf33dd 100644 --- a/lib/kernel/src/group.erl +++ b/lib/kernel/src/group.erl @@ -309,15 +309,17 @@ io_requests([], Stat, _) -> %% The ACK contains the return value. io_reply(From, ReplyAs, Reply) -> - From ! {io_reply,ReplyAs,Reply}. + From ! {io_reply,ReplyAs,Reply}, + ok. %% send_drv(Drv, Message) %% send_drv_reqs(Drv, Requests) send_drv(Drv, Msg) -> - Drv ! {self(),Msg}. + Drv ! {self(),Msg}, + ok. -send_drv_reqs(_Drv, []) -> []; +send_drv_reqs(_Drv, []) -> ok; send_drv_reqs(Drv, Rs) -> send_drv(Drv, {requests,Rs}). diff --git a/lib/kernel/src/heart.erl b/lib/kernel/src/heart.erl index 87cb9d7f51..daed6dd488 100644 --- a/lib/kernel/src/heart.erl +++ b/lib/kernel/src/heart.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2012. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. 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 @@ -182,20 +182,24 @@ wait_ack(Port) -> end. loop(Parent, Port, Cmd) -> - send_heart_beat(Port), + _ = send_heart_beat(Port), receive - {From, set_cmd, NewCmd} when length(NewCmd) < 2047 -> - send_heart_cmd(Port, NewCmd), - wait_ack(Port), - From ! {heart, ok}, - loop(Parent, Port, NewCmd); - {From, set_cmd, NewCmd} -> - From ! {heart, {error, {bad_cmd, NewCmd}}}, - loop(Parent, Port, Cmd); + {From, set_cmd, NewCmd0} -> + Enc = file:native_name_encoding(), + case catch unicode:characters_to_binary(NewCmd0,Enc,Enc) of + NewCmd when is_binary(NewCmd), byte_size(NewCmd) < 2047 -> + _ = send_heart_cmd(Port, NewCmd), + _ = wait_ack(Port), + From ! {heart, ok}, + loop(Parent, Port, NewCmd); + _ -> + From ! {heart, {error, {bad_cmd, NewCmd0}}}, + loop(Parent, Port, Cmd) + end; {From, clear_cmd} -> From ! {heart, ok}, - send_heart_cmd(Port, ""), - wait_ack(Port), + _ = send_heart_cmd(Port, ""), + _ = wait_ack(Port), loop(Parent, Port, ""); {From, get_cmd} -> From ! {heart, get_heart_cmd(Port)}, @@ -222,7 +226,7 @@ loop(Parent, Port, Cmd) -> -spec no_reboot_shutdown(port()) -> no_return(). no_reboot_shutdown(Port) -> - send_shutdown(Port), + _ = send_shutdown(Port), receive {'EXIT', Port, Reason} when Reason =/= badsig -> exit(normal) @@ -232,10 +236,10 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) -> unregister(?HEART_PORT_NAME), case catch start_portprogram() of {ok, NewPort} -> - send_shutdown(Port), + _ = send_shutdown(Port), receive {'EXIT', Port, _Reason} -> - send_heart_cmd(NewPort, Cmd), + _ = send_heart_cmd(NewPort, Cmd), Caller ! {heart, ok}, loop(Parent, NewPort, Cmd) after @@ -243,7 +247,7 @@ do_cycle_port_program(Caller, Parent, Port, Cmd) -> %% Huh! Two heart port programs running... %% well, the old one has to be sick not to respond %% so we'll settle for the new one... - send_heart_cmd(NewPort, Cmd), + _ = send_heart_cmd(NewPort, Cmd), Caller ! {heart, {error, stop_error}}, loop(Parent, NewPort, Cmd) end; diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl index 0a0e6003ee..e5928c7b63 100644 --- a/lib/kernel/src/hipe_unified_loader.erl +++ b/lib/kernel/src/hipe_unified_loader.erl @@ -194,6 +194,13 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) -> CodeSize, CodeBinary, Refs, 0,[] % ColdSize, CRrefs ] = binary_to_term(Bin), + ?debug_msg("***** ErLLVM *****~nVersion: ~s~nCheckSum: ~w~nConstAlign: ~w~n" ++ + "ConstSize: ~w~nConstMap: ~w~nLabelMap: ~w~nExportMap ~w~nRefs ~w~n", + [Version, CheckSum, ConstAlign, ConstSize, ConstMap, LabelMap, ExportMap, + Refs]), + %% Write HiPE binary code to a file in the current directory in order to + %% debug by disassembling. + %% file:write_file("erl.o", CodeBinary, [binary]), %% Check that we are loading up-to-date code. version_check(Version, Mod), case hipe_bifs:check_crc(CheckSum) of @@ -203,6 +210,7 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) -> "please regenerate native code for this runtime system\n", [Mod]), bad_crc; true -> + put(closures_to_patch, []), %% Create data segment {ConstAddr,ConstMap2} = create_data_segment(ConstAlign, ConstSize, ConstMap), @@ -220,17 +228,28 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) -> {MFAs,Addresses} = exports(ExportMap, CodeAddress), %% Remove references to old versions of the module. ReferencesToPatch = get_refs_from(MFAs, []), + %% io:format("References to patch: ~w~n", [ReferencesToPatch]), ok = remove_refs_from(MFAs), %% Patch all dynamic references in the code. %% Function calls, Atoms, Constants, System calls ok = patch(Refs, CodeAddress, ConstMap2, Addresses, TrampolineMap), + %% Tell the system where the loaded funs are. %% (patches the BEAM code to redirect to native.) case Beam of [] -> - export_funs(Addresses); + %% This module was previously loaded as BEAM code during system + %% start-up before the code server has started (-enable-native-libs + %% is active), so we must now patch the pre-existing entries in the + %% fun table with the native code addresses for all closures. + lists:foreach(fun({FE, DestAddress}) -> + hipe_bifs:set_native_address_in_fe(FE, DestAddress) + end, erase(closures_to_patch)), + export_funs(Addresses), + ok; BeamBinary when is_binary(BeamBinary) -> %% Find all closures in the code. + [] = erase(closures_to_patch), %Clean up, assertion. ClosurePatches = find_closure_patches(Refs), AddressesOfClosuresToPatch = calculate_addresses(ClosurePatches, CodeAddress, Addresses), @@ -243,6 +262,9 @@ load_common(Mod, Bin, Beam, OldReferencesToPatch) -> %% The call to export_funs/1 above updated the native addresses %% for the targets, so passing 'Addresses' is not needed. redirect(ReferencesToPatch), + %% Final clean up. + _ = erase(hipe_patch_closures), + _ = erase(hipe_assert_code_area), ?debug_msg("****************Loader Finished****************\n", []), {module,Mod} % for compatibility with code:load_file/1 end. @@ -560,12 +582,17 @@ patch_closure(DestMFA, Uniq, Index, Address, Addresses) -> case get(hipe_patch_closures) of false -> []; % This is taken care of when registering the module. - true -> % We are not loading a module patch these closures + true -> + %% We are replacing a previosly loaded BEAM module with native code, + %% so we must reference the pre-existing entries in the fun table + %% from the native code. We must delay actually patching the native + %% address into the fun entry to ensure that the native code cannot + %% be called until it has been completely fixed up. RemoteOrLocal = local, % closure code refs are local DestAddress = get_native_address(DestMFA, Addresses, RemoteOrLocal), BEAMAddress = hipe_bifs:fun_to_address(DestMFA), - FE = hipe_bifs:make_fe(DestAddress, mod(DestMFA), - {Uniq, Index, BEAMAddress}), + FE = hipe_bifs:get_fe(mod(DestMFA), {Uniq, Index, BEAMAddress}), + put(closures_to_patch, [{FE,DestAddress}|get(closures_to_patch)]), ?debug_msg("Patch FE(~w) to 0x~.16b->0x~.16b (emu:0x~.16b)\n", [DestMFA, FE, DestAddress, BEAMAddress]), ?ASSERT(assert_local_patch(Address)), diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index b1c9d56c2d..41d422d7d4 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2013. All Rights Reserved. +%% Copyright Ericsson AB 1997-2014. 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 @@ -457,7 +457,7 @@ gethostbyname(Name,Family) -> gethostbyname(Name,Family,Timeout) -> Timer = start_timer(Timeout), Res = gethostbyname_tm(Name,Family,Timer), - stop_timer(Timer), + _ = stop_timer(Timer), Res. gethostbyname_tm(Name,Family,Timer) -> @@ -488,7 +488,7 @@ gethostbyaddr(Address) -> gethostbyaddr(Address,Timeout) -> Timer = start_timer(Timeout), Res = gethostbyaddr_tm(Address, Timer), - stop_timer(Timer), + _ = stop_timer(Timer), Res. gethostbyaddr_tm(Address,Timer) -> @@ -543,7 +543,7 @@ getaddr(Address, Family) -> getaddr(Address, Family, Timeout) -> Timer = start_timer(Timeout), Res = getaddr_tm(Address, Family, Timer), - stop_timer(Timer), + _ = stop_timer(Timer), Res. getaddr_tm(Address, Family, Timer) -> @@ -569,7 +569,7 @@ getaddrs(Address, Family) -> getaddrs(Address, Family, Timeout) -> Timer = start_timer(Timeout), Res = getaddrs_tm(Address, Family, Timer), - stop_timer(Timer), + _ = stop_timer(Timer), Res. -spec getservbyport(Port :: port_number(), Protocol :: atom() | string()) -> @@ -597,8 +597,7 @@ getservbyname(Name, Protocol) when is_atom(Name) -> Error -> Error end. --spec ntoa(IpAddress) -> - {ok, Address} | {error, einval} when +-spec ntoa(IpAddress) -> Address | {error, einval} when Address :: string(), IpAddress :: ip_address(). ntoa(Addr) -> @@ -717,6 +716,9 @@ con_opt([Opt | Opts], R, As) -> false -> {error, badarg} end; + {active,N} when is_integer(N), N < 32768, N >= -32768 -> + NOpts = lists:keydelete(active, 1, R#connect_opts.opts), + con_opt(Opts, R#connect_opts { opts = [{active,N}|NOpts] }, As); {Name,Val} when is_atom(Name) -> con_add(Name, Val, R, Opts, As); _ -> {error, badarg} end; @@ -783,6 +785,9 @@ list_opt([Opt | Opts], R, As) -> false -> {error, badarg} end; + {active,N} when is_integer(N), N < 32768, N >= -32768 -> + NOpts = lists:keydelete(active, 1, R#listen_opts.opts), + list_opt(Opts, R#listen_opts { opts = [{active,N}|NOpts] }, As); {Name,Val} when is_atom(Name) -> list_add(Name, Val, R, Opts, As); _ -> {error, badarg} end; @@ -837,6 +842,9 @@ udp_opt([Opt | Opts], R, As) -> false -> {error, badarg} end; + {active,N} when is_integer(N), N < 32768, N >= -32768 -> + NOpts = lists:keydelete(active, 1, R#udp_opts.opts), + udp_opt(Opts, R#udp_opts { opts = [{active,N}|NOpts] }, As); {Name,Val} when is_atom(Name) -> udp_add(Name, Val, R, Opts, As); _ -> {error, badarg} end; @@ -855,7 +863,7 @@ udp_add(Name, Val, R, Opts, As) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Currently supported options include: % (*) {mode, list|binary} or just list|binary -% (*) {active, true|false|once} +% (*) {active, true|false|once|N} % (*) {sctp_module, inet_sctp|inet6_sctp} or just inet|inet6 % (*) options set via setsockopt. % The full list is below in sctp_options/0 . @@ -917,6 +925,9 @@ sctp_opt([Opt|Opts], Mod, R, As) -> false -> {error, badarg} end; + {active,N} when is_integer(N), N < 32768, N >= -32768 -> + NOpts = lists:keydelete(active, 1, R#sctp_opts.opts), + sctp_opt(Opts, Mod, R#sctp_opts { opts = [{active,N}|NOpts] }, As); {Name,Val} -> sctp_opt (Opts, Mod, R, As, Name, Val); _ -> {error,badarg} end; @@ -1495,7 +1506,7 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> {ok, A0} -> case A0 of false -> ok; - _ -> prim_inet:setopt(S, active, false) + _ -> ok = prim_inet:setopt(S, active, false) end, case tcp_sync_input(S, NewOwner, false) of true -> %% socket already closed, @@ -1506,7 +1517,7 @@ tcp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> unlink(S), %% unlink from port case A0 of false -> ok; - _ -> prim_inet:setopt(S, active, A0) + _ -> ok = prim_inet:setopt(S, active, A0) end, ok catch @@ -1549,13 +1560,12 @@ udp_controlling_process(S, NewOwner) when is_port(S), is_pid(NewOwner) -> {error, not_owner}; _ -> {ok, A0} = prim_inet:getopt(S, active), - prim_inet:setopt(S, active, false), + ok = prim_inet:setopt(S, active, false), udp_sync_input(S, NewOwner), try erlang:port_connect(S, NewOwner) of true -> unlink(S), - prim_inet:setopt(S, active, A0), - ok + ok = prim_inet:setopt(S, active, A0) catch error:Reason -> {error, Reason} diff --git a/lib/kernel/src/inet6_tcp_dist.erl b/lib/kernel/src/inet6_tcp_dist.erl index 2cb0e10c87..459fdc2ad5 100644 --- a/lib/kernel/src/inet6_tcp_dist.erl +++ b/lib/kernel/src/inet6_tcp_dist.erl @@ -92,7 +92,7 @@ accept_loop(Kernel, Listen) -> case inet6_tcp:accept(Listen) of {ok, Socket} -> Kernel ! {accept,self(),Socket,inet6,tcp}, - controller(Kernel, Socket), + _ = controller(Kernel, Socket), accept_loop(Kernel, Listen); Error -> exit(Error) diff --git a/lib/kernel/src/inet_config.erl b/lib/kernel/src/inet_config.erl index 2461f3ff25..fdc244f959 100644 --- a/lib/kernel/src/inet_config.erl +++ b/lib/kernel/src/inet_config.erl @@ -197,6 +197,9 @@ do_load_resolv({win32,Type}, longnames) -> win32_load_from_registry(Type), inet_db:set_lookup([native]); +do_load_resolv({ose,_}, _) -> + inet_db:set_lookup([file]); + do_load_resolv(_, _) -> inet_db:set_lookup([native]). diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl index a7679c531b..2ebdc0f554 100644 --- a/lib/kernel/src/inet_db.erl +++ b/lib/kernel/src/inet_db.erl @@ -1117,7 +1117,7 @@ handle_call(Request, From, #state{db=Db}=State) -> {set_cache_refresh, Time} when is_integer(Time), Time > 0 -> Time1 = ((Time+999) div 1000)*1000, %% round up ets:insert(Db, {cache_refresh_interval, Time1}), - stop_timer(State#state.cache_timer), + _ = stop_timer(State#state.cache_timer), {reply, ok, State#state{cache_timer = init_timer()}}; clear_hosts -> @@ -1131,7 +1131,7 @@ handle_call(Request, From, #state{db=Db}=State) -> reset -> reset_db(Db), - stop_timer(State#state.cache_timer), + _ = stop_timer(State#state.cache_timer), {reply, ok, State#state{cache_timer = init_timer()}}; {add_rc_list, List} -> @@ -1181,7 +1181,7 @@ handle_info(_Info, State) -> -spec terminate(term(), state()) -> 'ok'. terminate(_Reason, State) -> - stop_timer(State#state.cache_timer), + _ = stop_timer(State#state.cache_timer), ok. %%%---------------------------------------------------------------------- @@ -1240,8 +1240,9 @@ do_add_host(Byname, Byaddr, Names, Type, IP) -> ok. do_del_host(Byname, Byaddr, IP) -> - [ets:delete_object(Byname, {tolower(Name),Type,Addr}) || - {Name,Type,Addr} <- ets:lookup(Byaddr, IP)], + _ = + [ets:delete_object(Byname, {tolower(Name),Type,Addr}) || + {Name,Type,Addr} <- ets:lookup(Byaddr, IP)], ets:delete(Byaddr, IP), ok. diff --git a/lib/kernel/src/inet_gethost_native.erl b/lib/kernel/src/inet_gethost_native.erl index 65d4c84e3b..4320987078 100644 --- a/lib/kernel/src/inet_gethost_native.erl +++ b/lib/kernel/src/inet_gethost_native.erl @@ -237,7 +237,7 @@ handle_message({Port, {data, Data}}, State = #state{port = Port}) -> State; Req -> lists:foreach(fun({P,R,TR}) -> - ?CANCEL_TIMER(TR), + _= ?CANCEL_TIMER(TR), P ! {R, {ok, BinReply}} @@ -276,7 +276,7 @@ handle_message({timeout, Pid, RID}, State) -> {last, {LP,LR,_}} -> LP ! {LR, {error,timeout}}, %% Remove the whole request structure... - pick_request(State, RID), + _ = pick_request(State, RID), %% Also cancel the request to the port program... (catch port_command(State#state.port, <<RID:32,?OP_CANCEL_REQUEST>>)) @@ -517,7 +517,7 @@ do_start(Sup, C) -> {error, {{already_started, Pid}, _Child}} when is_pid(Pid) -> ok; {error, already_present} -> - supervisor:delete_child(Sup, Child), + _ = supervisor:delete_child(Sup, Child), do_start(Sup, C) end. diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl index 641a8dc0ca..889b596a22 100644 --- a/lib/kernel/src/inet_int.hrl +++ b/lib/kernel/src/inet_int.hrl @@ -46,6 +46,7 @@ -define(INET_PASSIVE, 0). -define(INET_ACTIVE, 1). -define(INET_ONCE, 2). % Active once then passive +-define(INET_MULTI, 3). % Active N then passive %% state codes (getstatus, INET_REQ_GETSTATUS) -define(INET_F_OPEN, 16#0001). diff --git a/lib/kernel/src/inet_parse.erl b/lib/kernel/src/inet_parse.erl index 98bd8d386c..a88c94a453 100644 --- a/lib/kernel/src/inet_parse.erl +++ b/lib/kernel/src/inet_parse.erl @@ -288,7 +288,7 @@ parse_file(_, File, Fn) -> case file:open(File, [read]) of {ok, Fd} -> Result = parse_fd(File,Fd, 1, Fn, []), - file:close(Fd), + _ = file:close(Fd), Result; Error -> Error end. diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl index 94a9f7c64d..6037da1d22 100644 --- a/lib/kernel/src/inet_res.erl +++ b/lib/kernel/src/inet_res.erl @@ -139,7 +139,7 @@ resolve(Name, Class, Type, Opts, Timeout) -> {ok, Nm} -> Timer = inet:start_timer(Timeout), Res = res_query(Nm, Class, Type, Opts, Timer), - inet:stop_timer(Timer), + _ = inet:stop_timer(Timer), Res; Error -> Error @@ -339,7 +339,7 @@ gethostbyaddr(IP) -> gethostbyaddr_tm(IP,false). gethostbyaddr(IP,Timeout) -> Timer = inet:start_timer(Timeout), Res = gethostbyaddr_tm(IP,Timer), - inet:stop_timer(Timer), + _ = inet:stop_timer(Timer), Res. gethostbyaddr_tm({A,B,C,D} = IP, Timer) when ?ip(A,B,C,D) -> @@ -424,7 +424,7 @@ gethostbyname(Name,Family) -> gethostbyname(Name,Family,Timeout) -> Timer = inet:start_timer(Timeout), Res = gethostbyname_tm(Name,Family,Timer), - inet:stop_timer(Timer), + _ = inet:stop_timer(Timer), Res. gethostbyname_tm(Name,inet,Timer) -> @@ -483,7 +483,7 @@ getbyname(Name, Type) -> getbyname(Name, Type, Timeout) -> Timer = inet:start_timer(Timeout), Res = getbyname_tm(Name, Type, Timer), - inet:stop_timer(Timer), + _ = inet:stop_timer(Timer), Res. getbyname_tm(Name, Type, Timer) when is_list(Name) -> @@ -921,18 +921,25 @@ query_tcp(Timeout, Id, Buffer, IP, Port, Verbose) -> [{active,false},{packet,2},binary,Family], Timeout) of {ok, S} -> - gen_tcp:send(S, Buffer), - case gen_tcp:recv(S, 0, Timeout) of - {ok, Answer} -> - gen_tcp:close(S), - case decode_answer(Answer, Id, Verbose) of - {ok, _} = OK -> OK; - {error, badid} -> {error, servfail}; - Error -> Error + case gen_tcp:send(S, Buffer) of + ok -> + case gen_tcp:recv(S, 0, Timeout) of + {ok, Answer} -> + gen_tcp:close(S), + case decode_answer(Answer, Id, Verbose) of + {ok, _} = OK -> OK; + {error, badid} -> {error, servfail}; + Error -> Error + end; + Error -> + gen_tcp:close(S), + ?verbose(Verbose, "TCP server recv error: ~p\n", + [Error]), + Error end; Error -> gen_tcp:close(S), - ?verbose(Verbose, "TCP server recv error: ~p\n", + ?verbose(Verbose, "TCP server send error: ~p\n", [Error]), Error end; diff --git a/lib/kernel/src/inet_sctp.erl b/lib/kernel/src/inet_sctp.erl index 2d799d79fa..93528d305d 100644 --- a/lib/kernel/src/inet_sctp.erl +++ b/lib/kernel/src/inet_sctp.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2011. All Rights Reserved. +%% Copyright Ericsson AB 2007-2013. 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 @@ -135,7 +135,7 @@ connect_get_assoc(S, Addr, Port, Active, Timer) -> {sctp,S,Addr,Port,{_,#sctp_assoc_change{state=St}=Ev}} -> case Active of once -> - prim_inet:setopt(S, active, once); + ok = prim_inet:setopt(S, active, once); _ -> ok end, if St =:= comm_up -> diff --git a/lib/kernel/src/inet_tcp_dist.erl b/lib/kernel/src/inet_tcp_dist.erl index 8005eff58c..63f236b069 100644 --- a/lib/kernel/src/inet_tcp_dist.erl +++ b/lib/kernel/src/inet_tcp_dist.erl @@ -119,7 +119,7 @@ accept_loop(Kernel, Listen) -> case inet_tcp:accept(Listen) of {ok, Socket} -> Kernel ! {accept,self(),Socket,inet,tcp}, - controller(Kernel, Socket), + _ = controller(Kernel, Socket), accept_loop(Kernel, Listen); Error -> exit(Error) diff --git a/lib/kernel/src/kernel.app.src b/lib/kernel/src/kernel.app.src index cb8c98ab06..5658c6b6cf 100644 --- a/lib/kernel/src/kernel.app.src +++ b/lib/kernel/src/kernel.app.src @@ -114,6 +114,7 @@ pg2]}, {applications, []}, {env, [{error_logger, tty}]}, - {mod, {kernel, []}} + {mod, {kernel, []}}, + {runtime_dependencies, ["erts-6.0", "stdlib-2.0", "sasl-2.4"]} ] }. diff --git a/lib/kernel/src/kernel.appup.src b/lib/kernel/src/kernel.appup.src index 54628800a8..f8f4cc1ec2 100644 --- a/lib/kernel/src/kernel.appup.src +++ b/lib/kernel/src/kernel.appup.src @@ -1,7 +1,7 @@ %% -*- erlang -*- %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1999-2011. All Rights Reserved. +%% Copyright Ericsson AB 1999-2014. 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 @@ -16,12 +16,10 @@ %% %% %CopyrightEnd% {"%VSN%", - %% Up from - max two major revisions back - [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16 - {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15 - {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R14 - %% Down to - max two major revisions back - [{<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R16 - {<<"2\\.15(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R15 - {<<"2\\.14(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R14 + %% Up from - max one major revision back + [{<<"3\\.0(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R17 + {<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}],%% R16 + %% Down to - max one major revision back + [{<<"3\\.0(\\.[0-9]+)*">>,[restart_new_emulator]}, %% R17 + {<<"2\\.16(\\.[0-9]+)*">>,[restart_new_emulator]}] %% R16 }. diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl index 1e07620a3e..ecdb32424a 100644 --- a/lib/kernel/src/kernel.erl +++ b/lib/kernel/src/kernel.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. 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 @@ -32,8 +32,13 @@ start(_, []) -> case supervisor:start_link({local, kernel_sup}, kernel, []) of {ok, Pid} -> Type = get_error_logger_type(), - error_logger:swap_handler(Type), - {ok, Pid, []}; + case error_logger:swap_handler(Type) of + ok -> {ok, Pid, []}; + Error -> + %% Not necessary since the node will crash anyway: + exit(Pid, shutdown), + Error + end; Error -> Error end. diff --git a/lib/kernel/src/kernel_config.erl b/lib/kernel/src/kernel_config.erl index 48141cfa03..56defcb167 100644 --- a/lib/kernel/src/kernel_config.erl +++ b/lib/kernel/src/kernel_config.erl @@ -121,7 +121,7 @@ send_timeout(Timeout, Pid) -> end. wait_nodes(Mandatory, Optional) -> - net_kernel:monitor_nodes(true), + ok = net_kernel:monitor_nodes(true), lists:foreach(fun(Node) -> case net_adm:ping(Node) of pong -> self() ! {nodeup, Node}; @@ -129,7 +129,9 @@ wait_nodes(Mandatory, Optional) -> end end, Mandatory ++ Optional), - rec_nodes(Mandatory, Optional). + R = rec_nodes(Mandatory, Optional), + ok = net_kernel:monitor_nodes(false), + R. rec_nodes([], []) -> ok; rec_nodes(Mandatory, Optional) -> diff --git a/lib/kernel/src/net_adm.erl b/lib/kernel/src/net_adm.erl index 9b2dac9544..3f5eac7822 100644 --- a/lib/kernel/src/net_adm.erl +++ b/lib/kernel/src/net_adm.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2011. All Rights Reserved. +%% Copyright Ericsson AB 1996-2013. 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 @@ -133,7 +133,7 @@ dns_hostname(Hostname) -> -spec ping_list([atom()]) -> [atom()]. ping_list(Nodelist) -> - net_kernel:monitor_nodes(true), + ok = net_kernel:monitor_nodes(true), Sofar = ping_first(Nodelist, nodes()), collect_new(Sofar, Nodelist). @@ -159,7 +159,7 @@ collect_new(Sofar, Nodelist) -> collect_new([Node | Sofar], Nodelist) end after 3000 -> - net_kernel:monitor_nodes(false), + ok = net_kernel:monitor_nodes(false), Sofar end. diff --git a/lib/kernel/src/net_kernel.erl b/lib/kernel/src/net_kernel.erl index dd0071b914..04a0d94ebf 100644 --- a/lib/kernel/src/net_kernel.erl +++ b/lib/kernel/src/net_kernel.erl @@ -306,21 +306,21 @@ do_connect(Node, Type, WaitForBarred) -> %% Type = normal | hidden end. passive_connect_monitor(Parent, Node) -> - monitor_nodes(true,[{node_type,all}]), + ok = monitor_nodes(true,[{node_type,all}]), case lists:member(Node,nodes([connected])) of true -> - monitor_nodes(false,[{node_type,all}]), + ok = monitor_nodes(false,[{node_type,all}]), Parent ! {self(),true}; _ -> Ref = make_ref(), Tref = erlang:send_after(connecttime(),self(),Ref), receive Ref -> - monitor_nodes(false,[{node_type,all}]), + ok = monitor_nodes(false,[{node_type,all}]), Parent ! {self(), false}; {nodeup,Node,_} -> - monitor_nodes(false,[{node_type,all}]), - erlang:cancel_timer(Tref), + ok = monitor_nodes(false,[{node_type,all}]), + _ = erlang:cancel_timer(Tref), Parent ! {self(),true} end end. @@ -734,7 +734,7 @@ handle_info(transition_period_end, how = How}} = State) -> ?tckr_dbg(transition_period_ended), case How of - shorter -> Tckr ! {new_ticktime, T}; + shorter -> Tckr ! {new_ticktime, T}, done; _ -> done end, {noreply,State#state{tick = #tick{ticker = Tckr, time = T}}}; @@ -1573,9 +1573,10 @@ async_gen_server_reply(From, Msg) -> ok -> ok; nosuspend -> - spawn(fun() -> catch erlang:send(Pid, M, [noconnect]) end); + _ = spawn(fun() -> catch erlang:send(Pid, M, [noconnect]) end), + ok; noconnect -> ok; % The gen module takes care of this case. - {'EXIT', _}=EXIT -> - EXIT + {'EXIT', _} -> + ok end. diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index 9415593485..187fd0001b 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -67,7 +67,7 @@ unsetenv(_) -> %%% End of BIFs -spec type() -> {Osfamily, Osname} when - Osfamily :: unix | win32, + Osfamily :: unix | win32 | ose, Osname :: atom(). type() -> @@ -189,20 +189,25 @@ extensions() -> Command :: atom() | io_lib:chars(). cmd(Cmd) -> validate(Cmd), - case type() of - {unix, _} -> - unix_cmd(Cmd); - {win32, Wtype} -> - Command0 = case {os:getenv("COMSPEC"),Wtype} of - {false,windows} -> lists:concat(["command.com /c", Cmd]); - {false,_} -> lists:concat(["cmd /c", Cmd]); - {Cspec,_} -> lists:concat([Cspec," /c",Cmd]) - end, - %% open_port/2 awaits string() in Command, but io_lib:chars() can be - %% deep lists according to io_lib module description. - Command = lists:flatten(Command0), - Port = open_port({spawn, Command}, [stream, in, eof, hide]), - get_data(Port, []) + Bytes = case type() of + {unix, _} -> + unix_cmd(Cmd); + {win32, Wtype} -> + Command0 = case {os:getenv("COMSPEC"),Wtype} of + {false,windows} -> lists:concat(["command.com /c", Cmd]); + {false,_} -> lists:concat(["cmd /c", Cmd]); + {Cspec,_} -> lists:concat([Cspec," /c",Cmd]) + end, + %% open_port/2 awaits string() in Command, but io_lib:chars() can be + %% deep lists according to io_lib module description. + Command = lists:flatten(Command0), + Port = open_port({spawn, Command}, [stream, in, eof, hide]), + get_data(Port, []) + end, + String = unicode:characters_to_list(list_to_binary(Bytes)), + if %% Convert to unicode list if possible otherwise return bytes + is_list(String) -> String; + true -> Bytes end. unix_cmd(Cmd) -> @@ -225,7 +230,9 @@ unix_cmd(Cmd) -> %% and the commands are read from standard input. We set the %% $1 parameter for easy identification of the resident shell. %% --define(SHELL, "/bin/sh -s unix:cmd 2>&1"). +-define(ROOT, "/"). +-define(ROOT_ANDROID, "/system"). +-define(SHELL, "bin/sh -s unix:cmd 2>&1"). -define(PORT_CREATOR_NAME, os_cmd_port_creator). %% @@ -275,7 +282,12 @@ start_port_srv(Request) -> end. start_port_srv_handle({Ref,Client}) -> - Reply = try open_port({spawn, ?SHELL},[stream]) of + Path = case lists:reverse(erlang:system_info(system_architecture)) of + % androideabi + "ibaediordna" ++ _ -> filename:join([?ROOT_ANDROID, ?SHELL]); + _ -> filename:join([?ROOT, ?SHELL]) + end, + Reply = try open_port({spawn, Path},[stream]) of Port when is_port(Port) -> (catch port_connect(Port, Client)), unlink(Port), @@ -284,8 +296,8 @@ start_port_srv_handle({Ref,Client}) -> error:Reason -> {Reason,erlang:get_stacktrace()} end, - Client ! {Ref,Reply}. - + Client ! {Ref,Reply}, + ok. start_port_srv_loop() -> receive @@ -293,7 +305,7 @@ start_port_srv_loop() -> is_pid(Client) -> start_port_srv_handle(Request); _Junk -> - ignore + ok end, start_port_srv_loop(). @@ -343,7 +355,7 @@ mk_cmd(Cmd) when is_atom(Cmd) -> % backward comp. mk_cmd(Cmd) -> %% We insert a new line after the command, in case the command %% contains a comment character. - io_lib:format("(~ts\n) </dev/null; echo \"\^D\"\n", [Cmd]). + [$(, unicode:characters_to_binary(Cmd), "\n) </dev/null; echo \"\^D\"\n"]. validate(Atom) when is_atom(Atom) -> @@ -351,7 +363,7 @@ validate(Atom) when is_atom(Atom) -> validate(List) when is_list(List) -> validate1(List). -validate1([C|Rest]) when is_integer(C), 0 =< C, C < 256 -> +validate1([C|Rest]) when is_integer(C) -> validate1(Rest); validate1([List|Rest]) when is_list(List) -> validate1(List), diff --git a/lib/kernel/src/pg2.erl b/lib/kernel/src/pg2.erl index 1ff10eb303..b562d4ffd2 100644 --- a/lib/kernel/src/pg2.erl +++ b/lib/kernel/src/pg2.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2012. All Rights Reserved. +%% Copyright Ericsson AB 1997-2013. 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 @@ -45,7 +45,7 @@ start() -> -spec create(Name :: name()) -> 'ok'. create(Name) -> - ensure_started(), + _ = ensure_started(), case ets:member(pg2_table, {group, Name}) of false -> global:trans({{?MODULE, Name}, self()}, @@ -60,7 +60,7 @@ create(Name) -> -spec delete(Name :: name()) -> 'ok'. delete(Name) -> - ensure_started(), + _ = ensure_started(), global:trans({{?MODULE, Name}, self()}, fun() -> gen_server:multi_call(?MODULE, {delete, Name}) @@ -71,7 +71,7 @@ delete(Name) -> when Name :: name(). join(Name, Pid) when is_pid(Pid) -> - ensure_started(), + _ = ensure_started(), case ets:member(pg2_table, {group, Name}) of false -> {error, {no_such_group, Name}}; @@ -88,7 +88,7 @@ join(Name, Pid) when is_pid(Pid) -> when Name :: name(). leave(Name, Pid) when is_pid(Pid) -> - ensure_started(), + _ = ensure_started(), case ets:member(pg2_table, {group, Name}) of false -> {error, {no_such_group, Name}}; @@ -105,7 +105,7 @@ leave(Name, Pid) when is_pid(Pid) -> when Name :: name(). get_members(Name) -> - ensure_started(), + _ = ensure_started(), case ets:member(pg2_table, {group, Name}) of true -> group_members(Name); @@ -117,7 +117,7 @@ get_members(Name) -> when Name :: name(). get_local_members(Name) -> - ensure_started(), + _ = ensure_started(), case ets:member(pg2_table, {group, Name}) of true -> local_group_members(Name); @@ -128,7 +128,7 @@ get_local_members(Name) -> -spec which_groups() -> [Name :: name()]. which_groups() -> - ensure_started(), + _ = ensure_started(), all_groups(). -spec get_closest_pid(Name) -> pid() | {'error', Reason} when @@ -165,7 +165,7 @@ get_closest_pid(Name) -> init([]) -> Ns = nodes(), - net_kernel:monitor_nodes(true), + ok = net_kernel:monitor_nodes(true), lists:foreach(fun(N) -> {?MODULE, N} ! {new_pg2, node()}, self() ! {nodeup, N} @@ -283,7 +283,7 @@ member_died(Ref) -> join_group(Name, Pid) -> Ref_Pid = {ref, Pid}, - try _ = ets:update_counter(pg2_table, Ref_Pid, {4, +1}) + try _ = ets:update_counter(pg2_table, Ref_Pid, {4, +1}), true catch _:_ -> {RPid, Ref} = do_monitor(Pid), true = ets:insert(pg2_table, {Ref_Pid, RPid, Ref, 1}), diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl index 0e7e7d2031..2300b7e901 100644 --- a/lib/kernel/src/rpc.erl +++ b/lib/kernel/src/rpc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2013. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. 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 @@ -66,7 +66,7 @@ %%------------------------------------------------------------------------ --type state() :: gb_tree(). +-type state() :: gb_trees:tree(pid(), {pid(), reference()}). %%------------------------------------------------------------------------ @@ -158,20 +158,20 @@ handle_info({Caller, {reply, Reply}}, S) -> {noreply, S} end; handle_info({From, {sbcast, Name, Msg}}, S) -> - case catch Name ! Msg of %% use catch to get the printout - {'EXIT', _} -> - From ! {?NAME, node(), {nonexisting_name, Name}}; - _ -> - From ! {?NAME, node(), node()} - end, + _ = case catch Name ! Msg of %% use catch to get the printout + {'EXIT', _} -> + From ! {?NAME, node(), {nonexisting_name, Name}}; + _ -> + From ! {?NAME, node(), node()} + end, {noreply, S}; handle_info({From, {send, Name, Msg}}, S) -> - case catch Name ! {From, Msg} of %% use catch to get the printout - {'EXIT', _} -> - From ! {?NAME, node(), {nonexisting_name, Name}}; - _ -> - ok %% It's up to Name to respond !!!!! - end, + _ = case catch Name ! {From, Msg} of %% use catch to get the printout + {'EXIT', _} -> + From ! {?NAME, node(), {nonexisting_name, Name}}; + _ -> + ok %% It's up to Name to respond !!!!! + end, {noreply, S}; handle_info({From, {call,Mod,Fun,Args,Gleader}}, S) -> %% Special for hidden C node's, uugh ... @@ -423,7 +423,7 @@ abcast(Name, Mess) -> abcast([Node|Tail], Name, Mess) -> Dest = {Name,Node}, case catch erlang:send(Dest, Mess, [noconnect]) of - noconnect -> spawn(erlang, send, [Dest,Mess]); + noconnect -> spawn(erlang, send, [Dest,Mess]), ok; _ -> ok end, abcast(Tail, Name, Mess); diff --git a/lib/kernel/src/seq_trace.erl b/lib/kernel/src/seq_trace.erl index a90b7b07c8..38a61f4644 100644 --- a/lib/kernel/src/seq_trace.erl +++ b/lib/kernel/src/seq_trace.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2011. All Rights Reserved. +%% Copyright Ericsson AB 1998-2013. 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 @@ -125,7 +125,7 @@ get_system_tracer() -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set_token2([{Type,Val}|T]) -> - erlang:seq_trace(Type, Val), + _ = erlang:seq_trace(Type, Val), set_token2(T); set_token2([]) -> ok. diff --git a/lib/kernel/src/standard_error.erl b/lib/kernel/src/standard_error.erl index e41dcd01fc..10cf77e0d4 100644 --- a/lib/kernel/src/standard_error.erl +++ b/lib/kernel/src/standard_error.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2010. All Rights Reserved. +%% Copyright Ericsson AB 2009-2013. 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 @@ -69,7 +69,7 @@ run(P) -> server_loop(Port) -> receive {io_request,From,ReplyAs,Request} when is_pid(From) -> - do_io_request(Request, From, ReplyAs, Port), + _ = do_io_request(Request, From, ReplyAs, Port), server_loop(Port); {'EXIT',Port,badsig} -> % Ignore badsig errors server_loop(Port); @@ -175,7 +175,7 @@ io_reply(From, ReplyAs, Reply) -> %% put_chars put_chars(Chars, Port) when is_binary(Chars) -> - put_port(Chars, Port), + _ = put_port(Chars, Port), {ok,ok}; put_chars(Chars, Port) -> case catch list_to_binary(Chars) of diff --git a/lib/kernel/src/user.erl b/lib/kernel/src/user.erl index c897d46bc2..40376ef752 100644 --- a/lib/kernel/src/user.erl +++ b/lib/kernel/src/user.erl @@ -103,11 +103,11 @@ catch_loop(Port, Shell, Q) -> {unknown_exit,{Shell,Reason},_} -> % shell has exited case Reason of normal -> - put_chars("*** ", Port, []); + put_port(<<"*** ">>, Port); _ -> - put_chars("*** ERROR: ", Port, []) + put_port(<<"*** ERROR: ">>, Port) end, - put_chars("Shell process terminated! ***\n", Port, []), + put_port(<<"Shell process terminated! ***\n">>, Port), catch_loop(Port, start_new_shell()); {unknown_exit,_,Q1} -> catch_loop(Port, Shell, Q1); @@ -181,7 +181,7 @@ get_fd_geometry(Port) -> do_io_request(Req, From, ReplyAs, Port, Q0) -> case io_request(Req, Port, Q0) of {_Status,Reply,Q1} -> - io_reply(From, ReplyAs, Reply), + _ = io_reply(From, ReplyAs, Reply), Q1; {exit,What} -> ok = send_port(Port, close), diff --git a/lib/kernel/src/user_drv.erl b/lib/kernel/src/user_drv.erl index 7b4ffb09ca..a91c23539d 100644 --- a/lib/kernel/src/user_drv.erl +++ b/lib/kernel/src/user_drv.erl @@ -488,21 +488,19 @@ set_unicode_state(Iport, Bool) -> %% io_request(Request, InPort, OutPort) %% io_requests(Requests, InPort, OutPort) - -io_request({put_chars, unicode,Cs}, _Iport, Oport) -> - Oport ! {self(),{command,[?OP_PUTC|unicode:characters_to_binary(Cs,utf8)]}}; -io_request({move_rel,N}, _Iport, Oport) -> - Oport ! {self(),{command,[?OP_MOVE|put_int16(N, [])]}}; -io_request({insert_chars,unicode,Cs}, _Iport, Oport) -> - Oport ! {self(),{command,[?OP_INSC|unicode:characters_to_binary(Cs,utf8)]}}; -io_request({delete_chars,N}, _Iport, Oport) -> - Oport ! {self(),{command,[?OP_DELC|put_int16(N, [])]}}; -io_request(beep, _Iport, Oport) -> - Oport ! {self(),{command,[?OP_BEEP]}}; -io_request({requests,Rs}, Iport, Oport) -> - io_requests(Rs, Iport, Oport); -io_request(_R, _Iport, _Oport) -> - ok. +%% Note: InPort is unused. + +io_request(Request, Iport, Oport) -> + try io_command(Request) of + Command -> + Oport ! {self(),Command}, + ok + catch + {requests,Rs} -> + io_requests(Rs, Iport, Oport); + _ -> + ok + end. io_requests([R|Rs], Iport, Oport) -> io_request(R, Iport, Oport), @@ -513,6 +511,19 @@ io_requests([], _Iport, _Oport) -> put_int16(N, Tail) -> [(N bsr 8)band 255,N band 255|Tail]. +io_command({put_chars, unicode,Cs}) -> + {command,[?OP_PUTC|unicode:characters_to_binary(Cs,utf8)]}; +io_command({move_rel,N}) -> + {command,[?OP_MOVE|put_int16(N, [])]}; +io_command({insert_chars,unicode,Cs}) -> + {command,[?OP_INSC|unicode:characters_to_binary(Cs,utf8)]}; +io_command({delete_chars,N}) -> + {command,[?OP_DELC|put_int16(N, [])]}; +io_command(beep) -> + {command,[?OP_BEEP]}; +io_command(Else) -> + throw(Else). + %% gr_new() %% gr_get_num(Group, Index) %% gr_get_info(Group, Pid) diff --git a/lib/kernel/src/wrap_log_reader.erl b/lib/kernel/src/wrap_log_reader.erl index 689269fc28..7e1f4aa07f 100644 --- a/lib/kernel/src/wrap_log_reader.erl +++ b/lib/kernel/src/wrap_log_reader.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2012. All Rights Reserved. +%% Copyright Ericsson AB 1998-2013. 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 @@ -149,7 +149,7 @@ open_int(File, FileNo, FirstFileNo) -> {ok, Head} -> case disk_log_1:is_head(Head) of no -> - file:close(Fd), + _ = file:close(Fd), {error, {not_a_log_file, FName}}; _ -> % yes or yes_not_closed case last_mod_time(FName) of @@ -161,12 +161,12 @@ open_int(File, FileNo, FirstFileNo) -> first_no = FirstFileNo}, {ok, WR}; {error, E} -> - file:close(Fd), + _ = file:close(Fd), {error, {file_error, FName, E}} end end; _Other -> - file:close(Fd), + _ = file:close(Fd), {error, {not_a_log_file, FName}} end; _Other -> @@ -280,7 +280,7 @@ read_next_file(WR, N, NewFileNo, Bad) -> true -> case open_int(File, NewFileNo, FirstFileNo) of {ok, NWR} -> - close(WR), %% Now we can safely close the old file. + _ = close(WR), %% Now we can safely close the old file. chunk(NWR, N, Bad); Error -> Error |