aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-01-13 13:35:53 +0100
committerBjörn Gustavsson <[email protected]>2016-01-20 12:32:58 +0100
commitca1964e765595dfe9089759adb5ef5eded4f2bf1 (patch)
treedbd180c67d62d2f2f080640e478b7cc9673229cc /erts
parent7189317ef89dfedaa35a804dfedd4fc27bf28d14 (diff)
downloadotp-ca1964e765595dfe9089759adb5ef5eded4f2bf1.tar.gz
otp-ca1964e765595dfe9089759adb5ef5eded4f2bf1.tar.bz2
otp-ca1964e765595dfe9089759adb5ef5eded4f2bf1.zip
erl_prim_loader: Correct purging of the archive cache
prim_do_release_archives/3 can't make up its mind whether the primary archive should be released or not. The key in the process dictionary is kept, while #prim_state.primary_archive is cleared. It seems that intent was the primary archive should be preserved, because the function was intended to be called by a timeout routine every sixth minute (it is not because of a bug in setting up the timeout). Therefore, rewrite the code to preserve the primary archive and simplify it while at it. Also, rename prim_release_archives/1 to prim_purge_cache/0 to make it clearer what it is doing.
Diffstat (limited to 'erts')
-rw-r--r--erts/preloaded/src/erl_prim_loader.erl47
1 files changed, 15 insertions, 32 deletions
diff --git a/erts/preloaded/src/erl_prim_loader.erl b/erts/preloaded/src/erl_prim_loader.erl
index 3ef48ad61e..ac461bc6c7 100644
--- a/erts/preloaded/src/erl_prim_loader.erl
+++ b/erts/preloaded/src/erl_prim_loader.erl
@@ -435,10 +435,6 @@ efile_set_primary_archive(#state{prim_state = PS} = State, File,
FileInfo, ParserFun),
{Res,State#state{prim_state = PS2}}.
-efile_release_archives(#state{prim_state = PS} = State) ->
- {Res, PS2} = prim_release_archives(PS),
- {Res,State#state{prim_state = PS2}}.
-
efile_list_dir(#state{prim_state = PS} = State, Dir) ->
{Res, PS2} = prim_list_dir(PS, Dir),
{Res, State#state{prim_state = PS2}}.
@@ -463,8 +459,8 @@ efile_exit_port(State, _Port, _Reason) ->
efile_timeout_handler(#state{n_timeouts = N} = State, _Parent) ->
if
N =< 0 ->
- {_Res, State2} = efile_release_archives(State),
- State2#state{n_timeouts = ?N_TIMEOUTS};
+ prim_purge_cache(),
+ State#state{n_timeouts = ?N_TIMEOUTS};
true ->
State#state{n_timeouts = N - 1}
end.
@@ -733,32 +729,19 @@ prim_init() ->
end,
cache_new(#prim_state{debug = Deb}).
-prim_release_archives(PS) ->
- debug(PS, release_archives),
- {Res, PS2} = prim_do_release_archives(PS, get(), []),
- debug(PS2, {return, Res}),
- {Res, PS2}.
-
-prim_do_release_archives(PS, [{ArchiveFile, DictVal} | KeyVals], Acc) ->
- Res =
- case DictVal of
- {primary, _PrimZip, _FI, _ParserFun} ->
- ok; % Keep primary archive
- {Cache, _FI} ->
- debug(PS, {release, cache, ArchiveFile}),
- erase(ArchiveFile),
- clear_cache(ArchiveFile, Cache)
- end,
- case Res of
- ok ->
- prim_do_release_archives(PS, KeyVals, Acc);
- {error, Reason} ->
- prim_do_release_archives(PS, KeyVals, [{ArchiveFile, Reason} | Acc])
- end;
-prim_do_release_archives(PS, [], []) ->
- {ok, PS#prim_state{primary_archive = undefined}};
-prim_do_release_archives(PS, [], Errors) ->
- {{error, Errors}, PS#prim_state{primary_archive = undefined}}.
+prim_purge_cache() ->
+ do_prim_purge_cache(get()).
+
+do_prim_purge_cache([{Key,Val}|T]) ->
+ case Val of
+ {Cache,_FI} ->
+ catch clear_cache(Key, Cache);
+ _ ->
+ ok
+ end,
+ do_prim_purge_cache(T);
+do_prim_purge_cache([]) ->
+ ok.
prim_set_primary_archive(PS, undefined, undefined, undefined, _ParserFun) ->
debug(PS, {set_primary_archive, clean}),