diff options
author | Steven Gravell <[email protected]> | 2010-09-19 18:48:24 +0100 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2011-03-21 15:46:47 +0100 |
commit | c425230a40c85c343538d88fccf278bc4ec569c5 (patch) | |
tree | 6229714d8c5ef5ccfbfce62d22a0d968ee53909e /lib/sasl/src/release_handler_1.erl | |
parent | b915bb2da3e5f507439df3ee8e259fb0a9bc424e (diff) | |
download | otp-c425230a40c85c343538d88fccf278bc4ec569c5.tar.gz otp-c425230a40c85c343538d88fccf278bc4ec569c5.tar.bz2 otp-c425230a40c85c343538d88fccf278bc4ec569c5.zip |
Remove traces of release_handler reading from filesystem when it has Masters list
There are a couple of places in release_handler and release_handler_1
that assumed it has a disk to read from, which in the case of an
erl_prim_loader Loader other than efile is not necessarily true
Add check_paths/2 to do the equivalent of check_path/1 for when there
is a Masters list
Change get_vsn to no longer get sent File paths but instead use the
Bin since beam_lib:version being sent a file path causes it to read
the local file system
Add get_current_vsn/1 as an equivalent to
beam_lib:version(code:which(Mod)), but using erl_prim_loader:get_file
instead of reading from local file system
Diffstat (limited to 'lib/sasl/src/release_handler_1.erl')
-rw-r--r-- | lib/sasl/src/release_handler_1.erl | 44 |
1 files changed, 31 insertions, 13 deletions
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; |