diff options
author | Ingela Andin <[email protected]> | 2017-06-02 09:38:54 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2017-06-02 09:38:54 +0200 |
commit | 575679c925df55e9937b2de9c9d059affa0e3594 (patch) | |
tree | f0601bf002bba864aaa36a053cf535a4549c6881 /lib/ssl/src/tls_connection.erl | |
parent | 98593ac959344debdbfe00992fc48c4fee365b7e (diff) | |
parent | 7f33b438a21b65663338a32d05983b76bdb1ef28 (diff) | |
download | otp-575679c925df55e9937b2de9c9d059affa0e3594.tar.gz otp-575679c925df55e9937b2de9c9d059affa0e3594.tar.bz2 otp-575679c925df55e9937b2de9c9d059affa0e3594.zip |
Merge pull request #1479 from weisslj/fix-missing-ssl-close
Correct close semantics for active once connections. This was a timing dependent bug the resulted in the close message not always reaching the ssl user process.
OTP-14443
Diffstat (limited to 'lib/ssl/src/tls_connection.erl')
-rw-r--r-- | lib/ssl/src/tls_connection.erl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/ssl/src/tls_connection.erl b/lib/ssl/src/tls_connection.erl index 96c3ab86e9..352874c77d 100644 --- a/lib/ssl/src/tls_connection.erl +++ b/lib/ssl/src/tls_connection.erl @@ -600,8 +600,12 @@ next_record(#state{protocol_buffers = next_record(#state{protocol_buffers = #protocol_buffers{tls_packets = [], tls_cipher_texts = []}, socket = Socket, transport_cb = Transport} = State) -> - tls_socket:setopts(Transport, Socket, [{active,once}]), - {no_record, State}; + case tls_socket:setopts(Transport, Socket, [{active,once}]) of + ok -> + {no_record, State}; + _ -> + {socket_closed, State} + end; next_record(State) -> {no_record, State}. @@ -626,10 +630,15 @@ passive_receive(State0 = #state{user_data_buffer = Buffer}, StateName) -> next_event(StateName, Record, State) -> next_event(StateName, Record, State, []). +next_event(StateName, socket_closed, State, _) -> + ssl_connection:handle_normal_shutdown(?ALERT_REC(?FATAL, ?CLOSE_NOTIFY), StateName, State), + {stop, {shutdown, transport_closed}, State}; next_event(connection = StateName, no_record, State0, Actions) -> case next_record_if_active(State0) of {no_record, State} -> ssl_connection:hibernate_after(StateName, State, Actions); + {socket_closed, State} -> + next_event(StateName, socket_closed, State, Actions); {#ssl_tls{} = Record, State} -> {next_state, StateName, State, [{next_event, internal, {protocol_record, Record}} | Actions]}; {#alert{} = Alert, State} -> |