aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2016-12-19 11:18:12 +0100
committerIngela Anderton Andin <[email protected]>2016-12-19 11:18:12 +0100
commit1715b9284643150da0f3ea43df42df1a4a90e144 (patch)
treed2c8897e36a290ade1a70aea178b6d138c168bcb /lib
parenta92eef5de3c1978d005747394473ba9fcab6407c (diff)
parentdd985c2097a29ca0812fdf6f0431aed2d8a7c752 (diff)
downloadotp-1715b9284643150da0f3ea43df42df1a4a90e144.tar.gz
otp-1715b9284643150da0f3ea43df42df1a4a90e144.tar.bz2
otp-1715b9284643150da0f3ea43df42df1a4a90e144.zip
Merge branch 'ingela/ssl/terminate/OTP-14100' into maint
* ingela/ssl/terminate/OTP-14100: ssl: Correct terminate behaviour
Diffstat (limited to 'lib')
-rw-r--r--lib/ssl/src/ssl_connection.erl11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/ssl/src/ssl_connection.erl b/lib/ssl/src/ssl_connection.erl
index 6e7c8c5ddd..6ed2fc83da 100644
--- a/lib/ssl/src/ssl_connection.erl
+++ b/lib/ssl/src/ssl_connection.erl
@@ -864,11 +864,11 @@ handle_call({close, {Pid, Timeout}}, From, StateName, State0, Connection) when i
%% When downgrading an TLS connection to a transport connection
%% we must recive the close alert from the peer before releasing the
%% transport socket.
- {next_state, downgrade, State, [{timeout, Timeout, downgrade}]};
+ {next_state, downgrade, State#state{terminated = true}, [{timeout, Timeout, downgrade}]};
handle_call({close, _} = Close, From, StateName, State, Connection) ->
%% Run terminate before returning so that the reuseaddr
- %% inet-option
- Result = Connection:terminate(Close, StateName, State),
+ %% inet-option works properly
+ Result = Connection:terminate(Close, StateName, State#state{terminated = true}),
{stop_and_reply, {shutdown, normal},
{reply, From, Result}, State};
handle_call({shutdown, How0}, From, _,
@@ -1010,7 +1010,10 @@ handle_info(Msg, StateName, #state{socket = Socket, error_tag = Tag} = State) ->
terminate(_, _, #state{terminated = true}) ->
%% Happens when user closes the connection using ssl:close/1
%% we want to guarantee that Transport:close has been called
- %% when ssl:close/1 returns.
+ %% when ssl:close/1 returns unless it is a downgrade where
+ %% we want to guarantee that close alert is recived before
+ %% returning. In both cases terminate has been run manually
+ %% before run by gen_statem which will end up here
ok;
terminate({shutdown, transport_closed} = Reason,