diff options
author | Björn Gustavsson <[email protected]> | 2011-09-28 11:13:59 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-09-28 11:13:59 +0200 |
commit | be8538809c571441e6543a677db58501634b7572 (patch) | |
tree | 25b9229f4c16064d4831e357cb3dbde256331322 /lib/stdlib | |
parent | 6bdf396b23219af136a217276308212913ca0aed (diff) | |
parent | b83073436a39553da458b19ef572ded9cd051611 (diff) | |
download | otp-be8538809c571441e6543a677db58501634b7572.tar.gz otp-be8538809c571441e6543a677db58501634b7572.tar.bz2 otp-be8538809c571441e6543a677db58501634b7572.zip |
Merge branch 'dev' into major
* dev:
distribution_SUITE:bulk_send_bigbig/1: Fail with more information
distribution_SUITE: Use unique slave node names
beam_lib: Handle rare race in the crypto key server functionality
busy_port_SUITE: Avoid crash in register/2
[wx] Re-generate code
[wx] Remove optional shadowing clauses
[wx] Remove warning
[wx] Fix trailing whitespace
[wx] Test colors in textctrl
[wx] Fix cleanup memory references
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/beam_lib.erl | 14 | ||||
-rw-r--r-- | lib/stdlib/test/beam_lib_SUITE.erl | 10 |
2 files changed, 19 insertions, 5 deletions
diff --git a/lib/stdlib/src/beam_lib.erl b/lib/stdlib/src/beam_lib.erl index 9077e59fdc..e9a5e6831e 100644 --- a/lib/stdlib/src/beam_lib.erl +++ b/lib/stdlib/src/beam_lib.erl @@ -896,13 +896,17 @@ call_crypto_server(Req) -> gen_server:call(?CRYPTO_KEY_SERVER, Req, infinity) catch exit:{noproc,_} -> - start_crypto_server(), - erlang:yield(), - call_crypto_server(Req) + %% Not started. + call_crypto_server_1(Req); + exit:{normal,_} -> + %% The process finished just as we called it. + call_crypto_server_1(Req) end. -start_crypto_server() -> - gen_server:start({local,?CRYPTO_KEY_SERVER}, ?MODULE, [], []). +call_crypto_server_1(Req) -> + gen_server:start({local,?CRYPTO_KEY_SERVER}, ?MODULE, [], []), + erlang:yield(), + call_crypto_server(Req). -spec init([]) -> {'ok', #state{}}. diff --git a/lib/stdlib/test/beam_lib_SUITE.erl b/lib/stdlib/test/beam_lib_SUITE.erl index b7fb1f618f..3f67db09c2 100644 --- a/lib/stdlib/test/beam_lib_SUITE.erl +++ b/lib/stdlib/test/beam_lib_SUITE.erl @@ -584,8 +584,18 @@ do_encrypted_abstr(Beam, Key) -> ?line {ok,{simple,[{"Abst",Abst}]}} = beam_lib:chunks(Beam, ["Abst"]), ?line {ok,cleared} = beam_lib:clear_crypto_key_fun(), + + %% Try to force a stop/start race. + ?line start_stop_race(10000), + ok. +start_stop_race(0) -> + ok; +start_stop_race(N) -> + {error,_} = beam_lib:crypto_key_fun(bad_fun), + undefined = beam_lib:clear_crypto_key_fun(), + start_stop_race(N-1). bad_fun(F) -> {error,E} = beam_lib:crypto_key_fun(F), |