aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-09-28 11:08:06 +0200
committerBjörn Gustavsson <[email protected]>2011-09-28 11:08:06 +0200
commitb83073436a39553da458b19ef572ded9cd051611 (patch)
tree2f26fb6d7f55dcc1b617fd3b9f652d2fb259547e /lib/stdlib/src
parenta1e73008b8dc8161922b1a47ffad4a4b61885ef8 (diff)
parentbc4362edacedb40c6edb9e855aa234c066b8292f (diff)
downloadotp-b83073436a39553da458b19ef572ded9cd051611.tar.gz
otp-b83073436a39553da458b19ef572ded9cd051611.tar.bz2
otp-b83073436a39553da458b19ef572ded9cd051611.zip
Merge branch 'bjorn/stdlib/fix-beam_lib-race/OTP-9586' into dev
* bjorn/stdlib/fix-beam_lib-race/OTP-9586: beam_lib: Handle rare race in the crypto key server functionality
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/beam_lib.erl14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/stdlib/src/beam_lib.erl b/lib/stdlib/src/beam_lib.erl
index d9c645d787..fdfbb2e998 100644
--- a/lib/stdlib/src/beam_lib.erl
+++ b/lib/stdlib/src/beam_lib.erl
@@ -893,13 +893,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{}}.