amqp10_client: Handle `close` message in the `open_sent` state
[Why] Without this, the connection process crashes. We see this happenning in CI frequently.
This commit is contained in:
parent
2c66191043
commit
77e3636272
|
|
@ -287,6 +287,22 @@ open_sent({call, From}, begin_session,
|
||||||
#state{pending_session_reqs = PendingSessionReqs} = State) ->
|
#state{pending_session_reqs = PendingSessionReqs} = State) ->
|
||||||
State1 = State#state{pending_session_reqs = [From | PendingSessionReqs]},
|
State1 = State#state{pending_session_reqs = [From | PendingSessionReqs]},
|
||||||
{keep_state, State1};
|
{keep_state, State1};
|
||||||
|
open_sent(_EvtType, {close, Reason}, State) ->
|
||||||
|
%% TODO: stop all sessions writing
|
||||||
|
%% We could still accept incoming frames (See: 2.4.6)
|
||||||
|
case send_close(State, Reason) of
|
||||||
|
ok ->
|
||||||
|
%% "After writing this frame the peer SHOULD continue to read from the connection
|
||||||
|
%% until it receives the partner's close frame (in order to guard against
|
||||||
|
%% erroneously or maliciously implemented partners, a peer SHOULD implement a
|
||||||
|
%% timeout to give its partner a reasonable time to receive and process the close
|
||||||
|
%% before giving up and simply closing the underlying transport mechanism)." [§2.4.3]
|
||||||
|
{next_state, close_sent, State, {state_timeout, ?TIMEOUT, received_no_close_frame}};
|
||||||
|
{error, closed} ->
|
||||||
|
{stop, normal, State};
|
||||||
|
Error ->
|
||||||
|
{stop, Error, State}
|
||||||
|
end;
|
||||||
open_sent(info, {'DOWN', MRef, process, _, _},
|
open_sent(info, {'DOWN', MRef, process, _, _},
|
||||||
#state{reader_m_ref = MRef}) ->
|
#state{reader_m_ref = MRef}) ->
|
||||||
{stop, {shutdown, reader_down}}.
|
{stop, {shutdown, reader_down}}.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue