diff options
author | Sverker Eriksson <[email protected]> | 2015-12-15 20:32:39 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-01-13 19:59:53 +0100 |
commit | fa44f865c3fc6253cf4691cf94839c303a3ee40f (patch) | |
tree | 47ec77902253825bceab86035a6c960b801188e2 /erts/preloaded/src/erlang.erl | |
parent | c612edf4ada1f00b2bdb8404103e0d8307dc8f4c (diff) | |
download | otp-fa44f865c3fc6253cf4691cf94839c303a3ee40f.tar.gz otp-fa44f865c3fc6253cf4691cf94839c303a3ee40f.tar.bz2 otp-fa44f865c3fc6253cf4691cf94839c303a3ee40f.zip |
erts: Make erlang:purge_module/1 safe
Problem: erlang:purge_module/1 is not safe in the sense
that very bad things may happen if the code to be purged
is still referred to by live processes.
Introduce erts_internal:purge_module which is the same as the old
erlang:purge_module BIF (except it returns false if no such old module).
Implement erlang:purge_module in Erlang and let it invoke
erts_code_purger for safe purging where all clogging processes
first are killed.
Diffstat (limited to 'erts/preloaded/src/erlang.erl')
-rw-r--r-- | erts/preloaded/src/erlang.erl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index d9dc9a1976..ab54d716cc 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -1471,8 +1471,16 @@ processes() -> %% purge_module/1 -spec purge_module(Module) -> true when Module :: atom(). -purge_module(_Module) -> - erlang:nif_error(undefined). +purge_module(Module) when erlang:is_atom(Module) -> + case erts_code_purger:purge(Module) of + {false, _} -> + erlang:error(badarg, [Module]); + {true, _} -> + true + end; +purge_module(Arg) -> + erlang:error(badarg, [Arg]). + %% put/2 -spec put(Key, Val) -> term() when |