diff options
author | Björn Gustavsson <bjorn@erlang.org> | 2010-10-19 13:43:13 +0200 |
---|---|---|
committer | Björn Gustavsson <bjorn@erlang.org> | 2010-10-20 12:02:08 +0200 |
commit | 7f82eddfaa3b89f734b4d58f1de92db86e5880cf (patch) | |
tree | d006dcb6f6c022ee875b32e75415c3793eb9cb7a /lib/kernel/test | |
parent | c09fa792fad151f43cd3fa3d998b666a91badc5e (diff) | |
download | otp-7f82eddfaa3b89f734b4d58f1de92db86e5880cf.tar.gz otp-7f82eddfaa3b89f734b4d58f1de92db86e5880cf.tar.bz2 otp-7f82eddfaa3b89f734b4d58f1de92db86e5880cf.zip |
Fix hang in on_load handlers in embedded mode
In embedded mode, all on_load handlers will be called after
loading all modules but before starting any servers. Therefore,
if an on_load handler calls any function in the code module that
calls the code server (such as code:priv_dir/1), there will be a
deadlock because the code server has not yet been started.
Fix this problem by invoking the on_load handlers after
having started most servers in the kernel application.
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl index a39332f81d..b7fdd4d9ae 100644 --- a/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl +++ b/lib/kernel/test/code_SUITE_data/on_load_app-1.0/src/on_load_embedded.erl @@ -3,6 +3,15 @@ -on_load(run_me/0). run_me() -> + %% An onload handler typically calls code:priv_dir/1 + %% or code:lib_dir/1, so make sure that it works. + LibDir = code:lib_dir(on_load_app), + PrivDir = code:priv_dir(on_load_app), + LibDir = filename:dirname(PrivDir), + ModPath = code:which(?MODULE), + LibDir = filename:dirname(filename:dirname(ModPath)), + + %% Start a process to remember that the on_load was called. spawn(fun() -> register(everything_is_fine, self()), receive Any -> |