diff options
author | Erlang/OTP <[email protected]> | 2009-12-14 13:03:38 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2009-12-14 13:03:38 +0000 |
commit | 1540714225f1d224ebeac73c711d673984edcf51 (patch) | |
tree | 01fe9e9d01700b815614a048a2a79efed6ec1ac2 /lib/kernel/src | |
parent | 47b882a585b5a226bd00b5125bac948ba9268c7f (diff) | |
parent | 1fe894432615e35f4ecbe3a33f8ba2ded21f8096 (diff) | |
download | otp-1540714225f1d224ebeac73c711d673984edcf51.tar.gz otp-1540714225f1d224ebeac73c711d673984edcf51.tar.bz2 otp-1540714225f1d224ebeac73c711d673984edcf51.zip |
Merge branch 'bg/on_load' into ccase/r13b04_dev
* bg/on_load:
Test on_load functions that don't return 'ok'
Change the expected return value for on_load functions
OTP-8339 The expected return value for an on_load function has been
changed. (See the section about code loading in the Reference
manual.)
Diffstat (limited to 'lib/kernel/src')
-rw-r--r-- | lib/kernel/src/code_server.erl | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl index 018f7f41d2..d4e3f0bcf8 100644 --- a/lib/kernel/src/code_server.erl +++ b/lib/kernel/src/code_server.erl @@ -1479,13 +1479,12 @@ finish_on_load(Ref, OnLoadRes, #state{on_load=OnLoad0,moddb=Db}=State) -> end. finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db) -> - Keep = if - is_boolean(OnLoadRes) -> OnLoadRes; - true -> false - end, + Keep = OnLoadRes =:= ok, erlang:finish_after_on_load(Mod, Keep), Res = case Keep of - false -> {error,on_load_failure}; + false -> + finish_on_load_report(Mod, OnLoadRes), + {error,on_load_failure}; true -> ets:insert(Db, {Mod,File}), {module,Mod} @@ -1493,6 +1492,24 @@ finish_on_load_1(Mod, File, OnLoadRes, WaitingPids, Db) -> [reply(Pid, Res) || Pid <- WaitingPids], ok. +finish_on_load_report(_Mod, Atom) when is_atom(Atom) -> + %% No error reports for atoms. + ok; +finish_on_load_report(Mod, Term) -> + %% Play it very safe here. The error_logger module and + %% modules it depend on may not be loaded yet and there + %% would be a dead-lock if we called it directly + %% from the code_server process. + spawn(fun() -> + F = "The on_load function for module " + "~s returned ~P\n", + + %% Express the call as an apply to simplify + %% the ext_mod_dep/1 test case. + E = error_logger, + E:warning_msg(F, [Mod,Term,10]) + end). + %% ------------------------------------------------------- %% Internal functions. %% ------------------------------------------------------- |