diff options
author | Tuncer Ayaz <[email protected]> | 2011-09-01 18:10:41 +0200 |
---|---|---|
committer | Tuncer Ayaz <[email protected]> | 2012-07-06 17:01:02 +0200 |
commit | 449a093a22af91403c36ca45c620d648d9110ab5 (patch) | |
tree | bd14241b3f7aadc92047c42c84a1181f257f409e /lib/stdlib/test/escript_SUITE_data | |
parent | c075ac6484e3d5a93a0d870ab4483d39ae26eaec (diff) | |
download | otp-449a093a22af91403c36ca45c620d648d9110ab5.tar.gz otp-449a093a22af91403c36ca45c620d648d9110ab5.tar.bz2 otp-449a093a22af91403c36ca45c620d648d9110ab5.zip |
[erts,kernel,stdlib] fix escript/primary archive reloading
If the mtime of an escript/primary archive file changes after being
added to the code path, correctly reload the archive and update the
cache.
The existing code didn't consider that it might be a zip archive and failed:
=ERROR REPORT==== 3-Aug-2011::09:21:21 ===
File operation error: bad_central_directory. Target:
/escript_archive/module.beam. Function: get_file. Process: code_server.
Thanks David Reid and Hakan Mattson.
Diffstat (limited to 'lib/stdlib/test/escript_SUITE_data')
-rw-r--r-- | lib/stdlib/test/escript_SUITE_data/archive_script/archive_script_main2.erl | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/stdlib/test/escript_SUITE_data/archive_script/archive_script_main2.erl b/lib/stdlib/test/escript_SUITE_data/archive_script/archive_script_main2.erl index de56579998..431a51b0e5 100644 --- a/lib/stdlib/test/escript_SUITE_data/archive_script/archive_script_main2.erl +++ b/lib/stdlib/test/escript_SUITE_data/archive_script/archive_script_main2.erl @@ -21,6 +21,8 @@ -export([main/1]). +-include_lib("kernel/include/file.hrl"). + -define(DUMMY, archive_script_dummy). -define(DICT, archive_script_dict). @@ -32,7 +34,7 @@ main(MainArgs) -> io:format("dummy:~p\n",[[E || E <- ErlArgs, element(1, E) =:= ?DUMMY]]), %% Start the applications - {error, {not_started, ?DICT}} = application:start(archive_script_dummy), + {error, {not_started, ?DICT}} = application:start(?DUMMY), ok = application:start(?DICT), ok = application:start(?DUMMY), @@ -57,4 +59,17 @@ main(MainArgs) -> ok = ?DICT:erase(Tab, Key), error = ?DICT:find(Tab, Key), ok = ?DICT:erase(Tab), + + %% Check mtime related caching bug with escript/primary archive files + Escript = escript:script_name(), + {ok, FileInfo} = file:read_file_info(Escript), + %% Modify mtime of archive file and try to reload module + FileInfo2 = FileInfo#file_info{mtime=calendar:now_to_local_time(now())}, + ok = file:write_file_info(Escript, FileInfo2), + Module = ?DICT, + {file, _} = code:is_loaded(Module), + true = code:delete(Module), + false = code:is_loaded(Module), + {module, Module} = code:ensure_loaded(Module), + ok. |