diff options
author | Siri Hansen <siri@erlang.org> | 2011-03-25 10:13:30 +0100 |
---|---|---|
committer | Siri Hansen <siri@erlang.org> | 2011-03-25 10:13:50 +0100 |
commit | ba7d76fcb401e831c1279fc22c96856603ff4c48 (patch) | |
tree | 1d4e35fd86a9ae1d580575b4716306a19178b1bf /lib/sasl/src | |
parent | 4370c71db54a62fa42100469921d66581f7f9a68 (diff) | |
parent | c425230a40c85c343538d88fccf278bc4ec569c5 (diff) | |
download | otp-ba7d76fcb401e831c1279fc22c96856603ff4c48.tar.gz otp-ba7d76fcb401e831c1279fc22c96856603ff4c48.tar.bz2 otp-ba7d76fcb401e831c1279fc22c96856603ff4c48.zip |
Merge branch 'sg/fix-diskless-booted-relup' into dev
* sg/fix-diskless-booted-relup:
Remove traces of release_handler reading from filesystem when it has
Masters list
OTP-9142
Diffstat (limited to 'lib/sasl/src')
-rw-r--r-- | lib/sasl/src/release_handler.erl | 42 | ||||
-rw-r--r-- | lib/sasl/src/release_handler_1.erl | 44 |
2 files changed, 60 insertions, 26 deletions
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl index 4c43277848..b60aa847df 100644 --- a/lib/sasl/src/release_handler.erl +++ b/lib/sasl/src/release_handler.erl @@ -791,7 +791,7 @@ check_rel(Root, RelFile, Masters) -> check_rel(Root, RelFile, LibDirs, Masters) -> case consult(RelFile, Masters) of {ok, [RelData]} -> - check_rel_data(RelData, Root, LibDirs); + check_rel_data(RelData, Root, LibDirs, Masters); {ok, _} -> throw({error, {bad_rel_file, RelFile}}); {error, Reason} when is_tuple(Reason) -> @@ -800,7 +800,8 @@ check_rel(Root, RelFile, LibDirs, Masters) -> throw({error, {FileError, RelFile}}) end. -check_rel_data({release, {Name, Vsn}, {erts, EVsn}, Libs}, Root, LibDirs) -> +check_rel_data({release, {Name, Vsn}, {erts, EVsn}, Libs}, Root, LibDirs, + Masters) -> Libs2 = lists:map(fun(LibSpec) -> Lib = element(1, LibSpec), @@ -810,7 +811,7 @@ check_rel_data({release, {Name, Vsn}, {erts, EVsn}, Libs}, Root, LibDirs) -> case lists:keysearch(Lib, 1, LibDirs) of {value, {_Lib, _Vsn, Dir}} -> Path = filename:join(Dir,LibName), - check_path(Path), + check_path(Path, Masters), Path; _ -> filename:join([Root, "lib", LibName]) @@ -820,19 +821,34 @@ check_rel_data({release, {Name, Vsn}, {erts, EVsn}, Libs}, Root, LibDirs) -> Libs), #release{name = Name, vsn = Vsn, erts_vsn = EVsn, libs = Libs2, status = unpacking}; -check_rel_data(RelData, _Root, _LibDirs) -> +check_rel_data(RelData, _Root, _LibDirs, _Masters) -> throw({error, {bad_rel_data, RelData}}). check_path(Path) -> - case file:read_file_info(Path) of - {ok, Info} when Info#file_info.type==directory -> - ok; - {ok, _Info} -> - throw({error, {not_a_directory, Path}}); - {error, _Reason} -> - throw({error, {no_such_directory, Path}}) - end. - + check_path_response(Path, file:read_file_info(Path)). +check_path(Path, false) -> check_path(Path); +check_path(Path, Masters) -> check_path_master(Masters, Path). + +%%----------------------------------------------------------------- +%% check_path at any master node. +%% If the path does not exist or is not a directory +%% at one node it should not exist at any other node either. +%%----------------------------------------------------------------- +check_path_master([Master|Ms], Path) -> + case rpc:call(Master, file, read_file_info, [Path]) of + {badrpc, _} -> consult_master(Ms, Path); + Res -> check_path_response(Path, Res) + end; +check_path_master([], _Path) -> + {error, no_master}. + +check_path_response(_Path, {ok, Info}) when Info#file_info.type==directory -> + ok; +check_path_response(Path, {ok, _Info}) -> + throw({error, {not_a_directory, Path}}); +check_path_response(Path, {error, _Reason}) -> + throw({error, {no_such_directory, Path}}). + do_check_install_release(RelDir, Vsn, Releases, Masters) -> case lists:keysearch(Vsn, #release.vsn, Releases) of {value, #release{status = current}} -> diff --git a/lib/sasl/src/release_handler_1.erl b/lib/sasl/src/release_handler_1.erl index 9c0edf4e99..8d050fb7b0 100644 --- a/lib/sasl/src/release_handler_1.erl +++ b/lib/sasl/src/release_handler_1.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2010. All Rights Reserved. +%% Copyright Ericsson AB 1996-2011. 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 @@ -20,7 +20,7 @@ %% External exports -export([eval_script/3, eval_script/4, check_script/2]). --export([get_vsn/1]). %% exported because used in a test case +-export([get_current_vsn/1]). %% exported because used in a test case -record(eval_state, {bins = [], stopped = [], suspended = [], apps = [], libdirs, unpurged = [], vsns = [], newlibs = [], @@ -223,7 +223,7 @@ eval({load_object_code, {Lib, LibVsn, Modules}}, EvalState) -> FName = filename:join(Ebin, File), case erl_prim_loader:get_file(FName) of {ok, Bin, FName2} -> - NVsns = add_new_vsn(Mod, FName2, Vsns), + NVsns = add_new_vsn(Mod, Bin, Vsns), {[{Mod, Bin, FName2} | Bins],NVsns}; error -> throw({error, {no_such_file,FName}}) @@ -609,17 +609,17 @@ sync_nodes(Id, Nodes) -> add_old_vsn(Mod, Vsns) -> case lists:keysearch(Mod, 1, Vsns) of {value, {Mod, undefined, NewVsn}} -> - OldVsn = get_vsn(code:which(Mod)), + OldVsn = get_current_vsn(Mod), lists:keyreplace(Mod, 1, Vsns, {Mod, OldVsn, NewVsn}); {value, {Mod, _OldVsn, _NewVsn}} -> Vsns; false -> - OldVsn = get_vsn(code:which(Mod)), + OldVsn = get_current_vsn(Mod), [{Mod, OldVsn, undefined} | Vsns] end. -add_new_vsn(Mod, File, Vsns) -> - NewVsn = get_vsn(File), +add_new_vsn(Mod, Bin, Vsns) -> + NewVsn = get_vsn(Bin), case lists:keysearch(Mod, 1, Vsns) of {value, {Mod, OldVsn, undefined}} -> lists:keyreplace(Mod, 1, Vsns, {Mod, OldVsn, NewVsn}); @@ -627,17 +627,35 @@ add_new_vsn(Mod, File, Vsns) -> [{Mod, undefined, NewVsn} | Vsns] end. - +%%----------------------------------------------------------------- +%% Func: get_current_vsn/1 +%% Args: Mod = atom() +%% Purpose: This function returns the equivalent of +%% beam_lib:version(code:which(Mod)), but it will also handle the +%% case when using erl_prim_loader loader different from 'efile'. +%% The reason for not using the Binary from the 'bins' or the +%% version directly from the 'vsns' state field is that these are +%% updated already by load_object_code, and this function is called +%% from load and remove. +%% Returns: Vsn = term() +%%----------------------------------------------------------------- +get_current_vsn(Mod) -> + File = code:which(Mod), + case erl_prim_loader:get_file(File) of + {ok, Bin, _File2} -> + get_vsn(Bin); + error -> + throw({error, {no_such_file, File}}) + end. %%----------------------------------------------------------------- %% Func: get_vsn/1 -%% Args: File = string() +%% Args: Bin = binary() %% Purpose: Finds the version attribute of a module. -%% Returns: Vsn -%% Vsn = term() +%% Returns: Vsn = term() %%----------------------------------------------------------------- -get_vsn(File) -> - {ok, {_Mod, Vsn}} = beam_lib:version(File), +get_vsn(Bin) -> + {ok, {_Mod, Vsn}} = beam_lib:version(Bin), case misc_supp:is_string(Vsn) of true -> Vsn; |