aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2018-01-02 17:58:30 +0100
committerIngela Anderton Andin <[email protected]>2018-01-04 11:14:54 +0100
commitd7e1ea1b59f0ba2b93bb0b9fea90533110c8afa1 (patch)
tree0cabae08e5398652d909077a0633ce976beeb927
parent97df070c819ac1a6781e542e891c3419b56c59df (diff)
downloadotp-d7e1ea1b59f0ba2b93bb0b9fea90533110c8afa1.tar.gz
otp-d7e1ea1b59f0ba2b93bb0b9fea90533110c8afa1.tar.bz2
otp-d7e1ea1b59f0ba2b93bb0b9fea90533110c8afa1.zip
ssl: Prevent error handling race condition
ERL-539
-rw-r--r--lib/ssl/src/tls_connection.erl6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl
index b033eea261..39f3ed996e 100644
--- a/lib/ssl/src/tls_connection.erl
+++ b/lib/ssl/src/tls_connection.erl
@@ -438,8 +438,10 @@ init(Type, Event, State) ->
error({call, From}, {start, _Timeout}, {Error, State}) ->
{stop_and_reply, normal, {reply, From, {error, Error}}, State};
-error({call, _} = Call, Msg, State) ->
- gen_handshake(?FUNCTION_NAME, Call, Msg, State);
+error({call, From}, {start, _Timeout}, #state{protocol_specific = #{error := Error}} = State) ->
+ {stop_and_reply, normal, {reply, From, {error, Error}}, State};
+error({call, _} = Call, Msg, {Error, #state{protocol_specific = Map} = State}) ->
+ gen_handshake(?FUNCTION_NAME, Call, Msg, State#state{protocol_specific = Map#{error => Error}});
error(_, _, _) ->
{keep_state_and_data, [postpone]}.